Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allows instrument.set() in active service worker #224

Merged
merged 1 commit into from
Oct 3, 2018

Conversation

romandev
Copy link
Member

@romandev romandev commented Nov 27, 2017

Like other service worker family features, we should only allow
instrument.set() in active service worker.

This fixes #223 issue.


Preview | Diff

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed text seems fine, but does this also apply to things like IndexedDB? Is there a pointer to an issue describing why we are adding this restriction? Just wondering what the rationale is.

@ianbjacobs
Copy link
Contributor

@romandev, we discussed this briefly at the editor call today and would like to request additional explanation of why you believe this change address issue #223. Thanks!

@romandev
Copy link
Member Author

Thank you for reviews and I'm sorry for delayed reply.
I was on long vacations last week.

This pull request is initiated from #223. The problem would not have happened before (bfe952b).
Because there was a spec text that it should wait for waiting/installing worker to become its active worker. We guessed the spec text was removed mistakenly. So, I'd like to restore the spec text from the large change.

One solution is navigator.serviceWorker.ready but it's not perfect.
For examples, there are the following issues:

  • What happens when calling register()/set() in redaundant service worker?
  • What happens in case of multiple registrations?

I think this patch can resolve them.

@romandev
Copy link
Member Author

The proposed text seems fine, but does this also apply to things like IndexedDB?

If my understanding is correct, IndexedDB storage is not associated with a service worker.
We might compare it with CacheStorage, BackgroundSync, and Push rather than IndexedDB.

The following link will be helpful to us:

@marcoscaceres
Copy link
Member

If my understanding is correct, IndexedDB storage is not associated with a service worker.

Ah, got it... it's "exposed" in a service worker, but not associated with it.

Right - I'm my mind the instruments were not bound to the service worker... that's again the discussion around storage and credentials.

@rsolomakhin
Copy link
Collaborator

@romandev: Shouldn't all the methods (.get(), .set(), .delete(), .has()) work only in an active service worker?

Like other service worker family features, we should only allow
instrument.set() in active service worker.

This fixes w3c#223 issue.
@romandev
Copy link
Member Author

romandev commented Oct 2, 2018

@rsolomakhin PTAL

I think other methods(get(), delete() and so on) no needs the check because instruments storage always empty before calling set().

get() will resolve undefined.
delete() will resolve false.
keys() will resolve empty array.
has() will resolve false.
clear() is unmeaningful because the storage is already empty.

@romandev
Copy link
Member Author

romandev commented Oct 2, 2018

FYI, when you wanna merge this or other PRs, according to #156, it's better to use a squash commit. (No merge commits)

I think merge commits make it difficult for us to track our commit history. :)

@rsolomakhin rsolomakhin merged commit e63b2d3 into w3c:gh-pages Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SW registration code unclear/incorrect
4 participants