[service workers][cache] cache.keys() returns an empty object

RESOLVED INVALID

Status

()

RESOLVED INVALID
4 years ago
4 years ago

People

(Reporter: opatinobugzilla, Assigned: bkelly)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
A service worker is running for the page. When the service worker executes cache.keys(), an empty object {} is returned. 
This happens when keys() is called with or without parameters. It should work for both.
(Assignee)

Updated

4 years ago
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
(Assignee)

Comment 1

4 years ago
Looking at the code you emailed:

  https://github.com/opatinowebrtc/opatinowebrtc.github.io/blob/master/js/service.js#L128

I see you are doing:

  debug(JSON.stringify(response));

This is an array of Request objects.  I don't think our webidl bound DOM objects serialize easily with JSON.stringify().  You probably need to inspect the attributes manually.

For example, when I do:

  dump(request.url)

Then I get a url string displayed.  If I do:

  dump(JSON.stringify(request))

Then I get {} displayed.
(Assignee)

Comment 2

4 years ago
Oscar, can you try changing your code to print request.url instead of using JSON.stringify()?
Flags: needinfo?(opatinobugzilla)
(Assignee)

Comment 3

4 years ago
To clarify, the spec does not provide a JSON serializer for these interfaces.
(Assignee)

Comment 4

4 years ago
I wrote a spec issue to suggest implementing serializers:

  https://github.com/whatwg/fetch/issues/22
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
(Assignee)

Comment 5

4 years ago
Oops... didn't mean to mark fixed.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(Reporter)

Comment 6

4 years ago
Thanks Ben,

in effect the problem was that I didn't notice that there were no serializer implemented for Response objects.
If I display response.url when calling keys() I get the array with all the entries in that cache.

I'm closing this bug then marking it as fixed
Flags: needinfo?(opatinobugzilla)
(Reporter)

Updated

4 years ago
Status: REOPENED → RESOLVED
Last Resolved: 4 years ago4 years ago
Resolution: --- → FIXED
Per comment 3 marking this bug as RESOLVED INVALID. Thanks!
Resolution: FIXED → INVALID
You need to log in before you can comment on or make changes to this bug.