Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix multithreading to work in Deno and Bun#25947

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Macil wants to merge1 commit intoemscripten-core:main
base:main
Choose a base branch
Loading
fromMacil:fixThreadingForDenoAndBun

Conversation

@Macil
Copy link

Fixesdenoland/deno#17171

Projects using Emscripten with pthreads don't work in Deno or Bun because those runtimes implement Web Worker APIs that Node doesn't, and Emscripten attempts to re-implement those APIs when running in Node/Deno/Bun in a way that conflicts with Deno and Bun's own implementations. This PR feature-detects Deno and Bun'spostMessage implementation and avoids setting up its own conflicting implementation in that case.

mfulton26 and scarf005 reacted with thumbs up emojisigmaSd reacted with hooray emoji
Copy link
Collaborator

@sbc100sbc100 left a comment

Choose a reason for hiding this comment

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

Nice!

We also now have some testing under bun as of#25903. Can you add 1 or more pthread-based tests to the lists of bun tests in.circleci/config.yml?

@MacilMacilforce-pushed thefixThreadingForDenoAndBun branch 6 times, most recently from60733b1 tob42b004CompareDecember 13, 2025 23:03
@MacilMacil marked this pull request as draftDecember 13, 2025 23:03
@MacilMacilforce-pushed thefixThreadingForDenoAndBun branch 7 times, most recently fromf9c2ff3 toab5c5c6CompareDecember 14, 2025 03:03
returnf;
}

constparentPort=worker_threads['parentPort'];
Copy link
Author

Choose a reason for hiding this comment

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

(The lines below were relying on this variable being set inruntime_common.js, which I had moved into an if-block and made not global. I discovered this after tests failed. I figured the simplest solution was to make this code use its own local variable instead of re-introducing the global variable.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

To save on code size and keep this patch as small as possible can you revert this and hoistconst parentPort = worker_threads['parentPort']; outside theif?

Also, we still usevar in most places in our codebase sadly (there are a couple of reasons, that are probably not worth explaining here... i really should create an FAQ entry or some such for it).

@MacilMacil marked this pull request as ready for reviewDecember 14, 2025 04:02
@Macil
Copy link
Author

I've added some pthread tests to the Bun tests and added some Deno tests too.

(I originally added a few tests for Deno that happened to use Emscripten'sPROXY_TO_PTHREAD option, but those tests failed. I spent a while debugging it so I could maybe fix that issue in this PR too, but it turns out to be becauseDeno doesn't implement Atomics.waitAsync.)

returnconfig.DENO_ENGINE
returnNone

defget_node_bun_or_deno(self):
Copy link
Author

Choose a reason for hiding this comment

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

(I'm not sure if some increasingly specific helper functions like this were the best route to go. One alternative would have been to make theget/require_node helpers to allow Deno/Bun too because they're mostly interchangeable, but it's probably better to be explicit. Another alternative would've been to make some generic helpers that take named parameters declaring which of Node/Node-Canary/Deno/Bun are allowed.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm hoping we can just avoid this completely, but allowing NODE_JS_TEST to be set to /path/to/bun or /path/to/deno. No need for new config vars I think/hope.

Macil reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

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

I embraced that idea and it's much simpler now.

Copy link
Collaborator

@sbc100sbc100 left a comment

Choose a reason for hiding this comment

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

To keep this change small and focused can you remove all the Deno stuff and we can consider that in a separate PR.

@MacilMacil marked this pull request as draftDecember 16, 2025 02:58
@MacilMacilforce-pushed thefixThreadingForDenoAndBun branch 4 times, most recently from29a7b1f toff084ddCompareDecember 16, 2025 03:46
@MacilMacil marked this pull request as ready for reviewDecember 16, 2025 03:56
Fixesdenoland/deno#17171Also adds several pthread tests with Bun
@MacilMacilforce-pushed thefixThreadingForDenoAndBun branch fromff084dd to5bd061cCompareDecember 16, 2025 03:58
ifoverride:
actual=override
else:
actual=utils.run_process(nodejs+ ['--version'],stdout=PIPE).stdout.strip()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally this change would live only in test/ code and only effectNODE_JS_TEST, not the main version of node js that we use.

i.e. can you make local function intest/common.py that does this override? Then use the local version instead ofshared.get_node_version?

Copy link
Collaborator

@sbc100sbc100 left a comment

Choose a reason for hiding this comment

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

Nice!

lgtm % one last comment

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

Reviewers

@sbc100sbc100sbc100 left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

node-compat: z3-solver

2 participants

@Macil@sbc100

[8]ページ先頭

©2009-2025 Movatter.jp