fix: allow for nesting workers#40
Merged
developit merged 1 commit intodevelopit:masterfrom Jan 4, 2024
Merged
Conversation
|
Hi @eshaz - any update on merging this? Would this also address #42? This should also be updated in your other package https://github.com/eshaz/wasm-audio-decoders which is using this as a dependency. |
developit
approved these changes
Jan 4, 2024
Owner
|
Thanks for taking the time to articulate the logic here, and sorry for taking forever to merge! This was released in 1.3.0. |
developit
pushed a commit
that referenced
this pull request
Jan 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an issue where it's not possible to use this library inside of a NodeJS worker thread, since the check below is not accounting for where the thread originated from. When using this library within a worker thread, the
workerThread()code is executed, rather than themainThread()code which creates the worker polyfill.web-worker/node.js
Line 73 in 29fef97
This change executes
workerThread()only if themodproperty is present from theworkerData, indicating that it's being executed from a thread created within this library. Ifmodisn't present, this means that the code is executing within the context of some other worker thread that wasn't created from this library, and it needs to treat the current thread as the main thread by executingmainThread().One enhancement might be to randomize the
modproperty name. This change assumes that a parent thread won't send amodproperty in theworkerData...