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 wasm workers under node #22721

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 11, 2024

  • Use callUserCallback to invoke callback in _wasmWorkerRunPostMessage.
    Without this calls to exit/emscripten_force_exit within the callback
    don't work as expected (they cause unhandled exception errors).
  • Fix onmessage handling under node so that the message payload always
    arrives as the data member of the message.
  • Update a few of the wasm workers tests do they actually exit (required
    for running tests under node).

@sbc100 sbc100 force-pushed the wasm_worker_node branch 4 times, most recently from f53fb7a to c02abb5 Compare October 11, 2024 19:08
@sbc100 sbc100 requested review from juj and kripken October 11, 2024 19:14
@sbc100 sbc100 force-pushed the wasm_worker_node branch 2 times, most recently from 9e79888 to ac37d0b Compare October 11, 2024 22:57
src/wasm_worker.js Outdated Show resolved Hide resolved
src/wasm_worker.js Show resolved Hide resolved
@sbc100 sbc100 force-pushed the wasm_worker_node branch 2 times, most recently from 1eb97cb to d20e9e0 Compare October 15, 2024 02:36
Copy link
Collaborator

@juj juj left a comment

Choose a reason for hiding this comment

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

LGTM. Though it is not precisely clear to me which part of this PR was the functional fix, and which part of the PR is nonfunctional/cleanup, since there are multiple orthogonal changes layered to this PR. (in particular, was refactoring to use callUserCallback() a needed correctness fix for Node, and was removing use of dynCalls in test_wasm_worker_terminate test necessary for Node?)

I feel a bit that if I proposed this PR, it might get reviewed to need to be split to multiple parts with nonfunctional and functional changes separate 😅 - but since I do argue towards having fast development ergonomy and flow, I think it's fine.

src/wasm_worker.js Outdated Show resolved Hide resolved
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 15, 2024

LGTM. Though it is not precisely clear to me which part of this PR was the functional fix, and which part of the PR is nonfunctional/cleanup, since there are multiple orthogonal changes layered to this PR. (in particular, was refactoring to use callUserCallback() a needed correctness fix for Node, and was removing use of dynCalls in test_wasm_worker_terminate test necessary for Node?)

I feel a bit that if I proposed this PR, it might get reviewed to need to be split to multiple parts with nonfunctional and functional changes separate 😅 - but since I do argue towards having fast development ergonomy and flow, I think it's fine.

I pretty sure everything here in the PR is essential to get the tests running under node. Sorry I should have documented in the PR description why each change is needed. I will do that now.

sbc100 added a commit that referenced this pull request Oct 17, 2024
We we not calling `writeStackCookie()` in the right place which means
that `checkStackCookie()` would always fail in wasm workers.

Required for #22721
@sbc100 sbc100 force-pushed the wasm_worker_node branch 2 times, most recently from ecec63e to f17ce9c Compare October 17, 2024 20:32
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 17, 2024

I updated the PR description to detail why these changes are needed and split out some parts into cleanup PRs.

sbc100 added a commit that referenced this pull request Oct 17, 2024
@sbc100 sbc100 enabled auto-merge (squash) October 17, 2024 21:17
- Use callUserCallback to invoke callback in _wasmWorkerRunPostMessage.
  Without this calls to exit/emscripten_force_exit within the callback
  don't work as expected (they cause unhandled exception errors).
- Fix `onmessage` handling under node so that the message payload always
  arrives as the `data` member of the message.
- Update a few of the wasm workers tests do they actually exit (required
  for running tests under node).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants