node-dev icon indicating copy to clipboard operation
node-dev copied to clipboard

support registering hook in worker threads

Open kherock opened this issue 2 years ago • 3 comments

This provides a better implementation for #285 by setting and reading the main script from process.env. This allows modules required from threads to trigger reloads.

I considered some alternative solutions where we monkeypatch into the Worker constructor, but ultimately I think an env variable solves this well

kherock avatar May 31 '22 01:05 kherock

Hi @bjornstar! Could this get a review please?

kherock avatar Jan 15 '23 18:01 kherock

I'd like to see a test so we can validate it's working.

bjornstar avatar Jan 16 '23 02:01 bjornstar

After adding a test case, I realized that it wasn't actually working as I expected - worker threads don't seem to inherit IPC handles, so I had to adapt the ipc.js helper to set up a new MessagePort as well.

kherock avatar Jan 16 '23 03:01 kherock