Skip to content
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

fix(ext/node): make worker setup synchronous #22815

Merged
merged 5 commits into from Mar 11, 2024

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Mar 8, 2024

This commit fixes race condition in "node:worker_threads" module were
the first message did a setup of "threadId", "workerData" and "environmentData".
Now this data is passed explicitly during workers creation and is set up
before any user code is executed.

Closes #22783
Closes #22672

ext/node/polyfills/worker_threads.ts Outdated Show resolved Hide resolved
runtime/js/99_main.js Outdated Show resolved Hide resolved
runtime/web_worker.rs Outdated Show resolved Hide resolved
@satyarohith satyarohith changed the title fix(ext/node): make worker setup synchronous [WIP] fix(ext/node): make worker setup synchronous Mar 11, 2024
@satyarohith satyarohith marked this pull request as ready for review March 11, 2024 18:13
Copy link
Member

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better. Do we have a test for the worker data being a shared array buffer?

Copy link
Member

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with follow-up PR planned

@bartlomieju bartlomieju merged commit d69aab6 into denoland:main Mar 11, 2024
17 checks passed
@bartlomieju bartlomieju deleted the poc_worker_data branch March 11, 2024 22:18
nathanwhit pushed a commit that referenced this pull request Mar 14, 2024
This commit fixes race condition in "node:worker_threads" module were
the first message did a setup of "threadId", "workerData" and
"environmentData".
Now this data is passed explicitly during workers creation and is set up
before any user code is executed.

Closes #22783
Closes #22672

---------

Co-authored-by: Satya Rohith <me@satyarohith.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants