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
Assert "mockServiceWorker" integrity #81
Comments
Starting from
Please, if you are using MSW prior to @kentcdodds, I know you are an active user of MSW so I wanted to ping you directly regarding these changes. Sorry for possible inconvenience, I hope the update goes smoothly for you, as this is a crucial change for the library’s future. Thanks. |
I just updated and I haven't gotten any console warnings yet. But I tried running
|
Also, I think there may be a bug with 0.11.0. I don't think it's initializing the msw service worker anymore. |
@kentcdodds, Thanks for getting back with this. Now I see I haven't whitelisted the |
I'm getting an integrity check failure even though I did re-init... |
Honestly, I see this integrity check as adding unnecessary complexity. I'd rather opt-into it. |
I just verified that the checksum that was created for me was different from the one that's inside msw... Not sure how that happened. Correct me if I'm wrong, but this checksum basically means that every time I update msw, I'll need to update the service worker? That would be a pretty annoying workflow... |
@kentcdodds sorry to hear that. It mat look like a redundant step, but once we get it right it’ll be worth it. Your feedback is helpful and I’ll look into the issue you’re experiencing. The integrity checksum is generated upon build before publishing the package. No matter what you do with MSW workflow, it must never change. You can see it in the The latest release should contain the integrity |
I understand that, but I really don't think it's worth the impact to everyone's workflow. Doing this would basically mean every time you upgrade packages you have to rerun the init. That would be super annoying. Totally not worth it. Please consider an opt-out at least. |
This basically protects me from myself by making me do extra work. But if I have the discipline to not change that file myself then I don't want to do the extra work. |
@kentcdodds the way checksum is generated is so it only updates if I'm not pushing for this kind of check and I'm open to discuss an alternative to keep the Service Worker and the library's logic in sync. I think what you are experiencing right now is a hiccup to get this check rolled out. I plan to make the process as painless as possible for the developer, so no extra actions are necessary, if there is no reason for it. Your feedback also helps a lot, and I'm once more sorry for the painful initial experience. Hope to polish this functionality to its best. I've bumped the version and see the integrity check pass on |
Perhaps, as a middle-ground the integrity assertion failure could still allow SW to mock responses. I'd consider such behavior as opt-in. |
Oh, I was confused. So it's not likely that there would be a problem because that file doesn't get updates very often. I think that's ok. Sorry for my misunderstanding, thank you for taking the time to explain it to me. |
It’s perfectly fine. I’m glad I was able to explain it better :) Please, does |
It does fix the integrity warning, but the service worker is no longer handling requests. I'm afraid I don't have time to investigate why, but if you want to try it out feel free: https://github.com/kentcdodds/bookshelf |
@kentcdodds, thanks for reporting the status. I'll take a look in the nearest time. |
@kentcdodds, I've addressed the issue in kentcdodds/bookshelf#26. It turned out that your application didn't have the latest Could you please take a look at the pull request? Thanks. |
Excellent. Thank you! |
Motivation
The library must assert the integrity of the
mockServiceWorker.js
file for multiple reasons:msw
packageImplementation
Publication
mockServiceWorker.js
file contentClient-side
start()
invocation to get the integrity information.npx init <PUBLIC_DIR>
to resolve the issue.The text was updated successfully, but these errors were encountered: