Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ jobs:
- upload-test-results
test-bun:
executor: linux-python
environment:
OVERRIDE_NODE_JS_VERSION: "v24.0.0"
steps:
- checkout
- pip-install
Expand All @@ -880,10 +882,14 @@ jobs:
name: install bun
command: |
curl -fsSL https://bun.com/install | bash
echo "BUN_ENGINE = os.path.expanduser('~/.bun/bin/bun')" >> ~/emsdk/.emscripten
echo "JS_ENGINES = [BUN_ENGINE]" >> ~/emsdk/.emscripten
echo "NODE_JS_TEST = os.path.expanduser('~/.bun/bin/bun')" >> ~/emsdk/.emscripten
echo "JS_ENGINES = [NODE_JS_TEST]" >> ~/emsdk/.emscripten
- run-tests:
test_targets: "core0.test_hello_world"
test_targets: "
core0.test_hello_world
core0.test_hello_argc_pthreads
core2.test_pthread_create
"
test-jsc:
executor: linux-python
steps:
Expand Down
15 changes: 9 additions & 6 deletions src/pthread_esm_startup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ console.log("Running pthread_esm_startup");
#if ENVIRONMENT_MAY_BE_NODE
if ({{{ nodeDetectionCode() }}}) {
// Create as web-worker-like an environment as we can.
globalThis.self = globalThis;
var worker_threads = await import('worker_threads');
global.Worker = worker_threads.Worker;
globalThis.Worker = worker_threads.Worker;
var parentPort = worker_threads['parentPort'];
parentPort.on('message', (msg) => global.onmessage?.({ data: msg }));
Object.assign(globalThis, {
self: global,
postMessage: (msg) => parentPort['postMessage'](msg),
});
// Deno and Bun already have `postMessage` defined on the global scope and
// deliver messages to `globalThis.onmessage`, so we must not duplicate that
// behavior here if `postMessage` is already present.
if (!globalThis.postMessage) {
parentPort.on('message', (msg) => globalThis.onmessage?.({ data: msg }));
globalThis.postMessage = (msg) => parentPort['postMessage'](msg);
}
}
#endif

Expand Down
13 changes: 8 additions & 5 deletions src/runtime_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ var readyPromiseResolve, readyPromiseReject;
#if (PTHREADS || WASM_WORKERS) && (ENVIRONMENT_MAY_BE_NODE && !WASM_ESM_INTEGRATION)
if (ENVIRONMENT_IS_NODE && {{{ ENVIRONMENT_IS_WORKER_THREAD() }}}) {
// Create as web-worker-like an environment as we can.
globalThis.self = globalThis;
var parentPort = worker_threads['parentPort'];
parentPort.on('message', (msg) => global.onmessage?.({ data: msg }));
Object.assign(globalThis, {
self: global,
postMessage: (msg) => parentPort['postMessage'](msg),
});
// Deno and Bun already have `postMessage` defined on the global scope and
// deliver messages to `globalThis.onmessage`, so we must not duplicate that
// behavior here if `postMessage` is already present.
if (!globalThis.postMessage) {
parentPort.on('message', (msg) => globalThis.onmessage?.({ data: msg }));
globalThis.postMessage = (msg) => parentPort['postMessage'](msg);
}
// Node.js Workers do not pass postMessage()s and uncaught exception events to the parent
// thread necessarily in the same order where they were generated in sequential program order.
// See https://github.com/nodejs/node/issues/59617
Expand Down
6 changes: 5 additions & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ def env_with_node_in_path():


def _get_node_version_pair(nodejs):
actual = utils.run_process(nodejs + ['--version'], stdout=PIPE).stdout.strip()
override = os.environ.get('OVERRIDE_NODE_JS_VERSION')
if override:
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 effect NODE_JS_TEST, not the main version of node js that we use.

i.e. can you make local function in test/common.py that does this override? Then use the local version instead of shared.get_node_version?

version = actual.removeprefix('v')
version = version.split('-')[0].split('.')
version = tuple(int(v) for v in version)
Expand Down