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

fixed registration problem of service worker #1807

Merged
merged 7 commits into from
Feb 15, 2021

Conversation

vivek-30
Copy link

Fixes #1138.

@vivek-30 vivek-30 requested a review from a team as a code owner February 10, 2021 01:49
@gitpod-io
Copy link

gitpod-io bot commented Feb 10, 2021

@vivek-30
Copy link
Author

@harshkhandeparkar , @jywarren Could you please review this ☺️

});
});

const installingWorker = registration.installing;
Copy link
Author

Choose a reason for hiding this comment

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

this is happening bcoz we have already checked service worker state as installed and now this state installing will not come again. so it returns a null on which we have just added a statechange event listener which is meaningless.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thank you!; this is so hard to track as maintainers; do you think it's possible to write a test for this?

Copy link
Author

Choose a reason for hiding this comment

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

I have tried to write test for this but i don't know how to make this run 😅 ?

you can have a look this test -
https://github.com/vivek-30/image-sequencer/blob/5fc7fc8ecbb02ac989605a4d422b7b8d85d67aeb/test/core/sw.test.js#L1-L72

@jywarren, @harshkhandeparkar could you please suggest me what to do?

Copy link
Author

Choose a reason for hiding this comment

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

Actually @jywarren what i think is even if we don't build a test for this then also it will solve this problem.
No doubt that adding test will ensure more security and safety but don't think it will slow down image sequencer as to check a successful installation of sw .we have to remove existing sw and clear out the cache and then register a new updated sw (which i have done in my test) ?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for giving it a try! If you add the test to the correct folder alongside others in this repo, it'll run within this PR. It's possible you need to add some more assertions -- like, see how this line confirms something we expect to be true about the test scenario:

t.equal(sequencer.steps.length, 1, 'Initial Step Created');

Want to try adding your test in this PR?

Copy link
Author

Choose a reason for hiding this comment

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

@jywarren plz have a look now ,i have added a test for this. Hope you like it ☺️

@vivek-30 vivek-30 requested a review from a team as a code owner February 12, 2021 12:32
var sw = require('../../examples/sw');
var test = require('tape');

function SWInstallation(registration){
Copy link
Member

Choose a reason for hiding this comment

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

Here, should we instead use the setupCache() method from our actual code, rather than make a unique worker management code segment within the tests? Does that make sense? What do you think? Then our assertions below ought to still pass, right?

Copy link
Author

Choose a reason for hiding this comment

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

sure sir ,it will avoid code duplication.
And i also thinks it will still pass.☺️

Copy link
Author

Choose a reason for hiding this comment

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

@jywarren could you please review these changes ☺️

@jywarren jywarren merged commit 0bdf71a into publiclab:main Feb 15, 2021
@jywarren
Copy link
Member

Thanks for sticking with this one @vivek-30 this was a complex one to fix and test and we appreciate it!!!!

@vivek-30
Copy link
Author

Thanks a lot sir 😊 . you really helped me to solve the issue.

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.

Service worker registration failed error in console
2 participants