question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make the worker updates half-automatic

See original GitHub issue

Current behavior

When the worker registers, the client-side of the library sends a message to it with the latest worker’s checksum to know if your app is running an outdated worker (worker has some changes in the latest version vs. the worker that’s currently running).

Disadvantages

  • Worker updates are not apparent. Users find out about them (if they do) only by seeing the console error in a browser.
  • Worker updates are manual, as you need to re-run the init command again.

Suggested behavior

The library can check if there’s a designated property set in the project’s package.json that indicates the public directory where the worker script is located (and has been previously instantiated).

// package.json
{
  "msw": {
    "workerDirectory": "./public"
  }
}

Inferring the public directory from other possible settings is a guessing game, as there’s no guarantee that the public directory is otherwise defined or equals to the directory where the user serves the worker script.

When such a relative directory path is provided, MSW will automatically excute the init <WORKER_DIR> command on the postinstall hook of the library. That way any updates (or downgrades) of the msw package are followed by updating the worker script automatically.

If the special property is not specified in package.json, nothing happens. Developer will still see an integrity mismatch error in a browser’s console and would be asked to update the worker script manually (via the CLI).

Advantages

  • Worker script updates become automatic.

Disadvantages

  • Developer needs to have a special field in package.json to enable this.
  • The worker script update becomes implicit, even despite the message printed in stdout.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
kentcdoddscommented, Feb 21, 2021

Yeah, let’s make sure that whatever the solution, when I run the app I can do so without any network connection. This is one of the more compelling use cases for MSW in the first place (and why I sought out a mocking library when I found MSW).

1reaction
kettanaitocommented, Feb 21, 2021

Absolutely agree: users must have the capability to develop their apps offline against mocks. We are not stepping down on this experience. After some work on postinstall script and about 20GB of disk space eaten by Yarn, I’ve managed to make it work. I think that’s the first step towards the update automation we’re going to take.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WORKER Mod Automatic Kits 130 Motor Semi Auto and ...
Made of high quality metal, electronic components and a durable PLA.The speed of push rod can be adjusted and the speed of shoot...
Read more >
Handling Service Worker updates – how to keep the app ...
For production readiness, we need to make sure our Service Worker will be ... further by ensuring the app is never running in...
Read more >
How to enable and disable the Outlook calendar sharing ...
Note: Shared Calendar improvements are now enabled by default in the most recent versions of Outlook, in all update channels for Microsoft 365...
Read more >
Why You Should Update to a Semi-Automatic Pallet Wrapper
Saving Time: Depending on the size of your pallet, wrapping each one by hand could take an unreasonable amount of time.
Read more >
SEMI AUTOMATIC MACHINE - Siemens Communities
Here is a basic implementation. I have summed up all individual automatic/manual steps into 3 main steps, as it's not necessary from simulation ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found