Skip to content

fix: allow importing inside a NodeJS worker with no workerData - #58

Open
DerZade wants to merge 1 commit into
developit:mainfrom
DerZade:main
Open

fix: allow importing inside a NodeJS worker with no workerData#58
DerZade wants to merge 1 commit into
developit:mainfrom
DerZade:main

Conversation

@DerZade

@DerZade DerZade commented Apr 9, 2026

Copy link
Copy Markdown

This PR fixes #57

I added a ?? {} to the threads.workerData destructuring to ensure we have a valid value to destructure.

In addition to that I added a new attribute with a unique name (includes a UUID, so it's basically impossible to set this by accident) to the workerData.
This ensures we can reliably verify that we are running in a worker thread, which was created by web-worker. All other threads will use the mainThread code path (and not the workerThread code path).
Something similar was already suggested by eshaz in #40:

[...]
One enhancement might be to randomize the mod property name. This change assumes that a parent thread won't send a mod property in the workerData...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant