Skip to content

Comments

Add WS dep to emscripten_websocket_new (fixes #26310)#26317

Closed
floooh wants to merge 1 commit intoemscripten-core:mainfrom
floooh:issue26310/fix_emscripten_websocket_new_deps
Closed

Add WS dep to emscripten_websocket_new (fixes #26310)#26317
floooh wants to merge 1 commit intoemscripten-core:mainfrom
floooh:issue26310/fix_emscripten_websocket_new_deps

Conversation

@floooh
Copy link
Collaborator

@floooh floooh commented Feb 21, 2026

This is a single-line fix to add a missing $WS dependency to the emscripten_websocket_new function.

See #26310 for details.

Not really a high-priority fix, since I guess emscripten_websocket_new is rarely used alone, and the other emscripten_websocket_* functions will pull in the same dependency anyway (for the same reason I think it's not worth to add a new test for this specific problem - I did test the fix locally though with the code in the issue).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a missing dependency in the WebSocket JS library so emscripten_websocket_new correctly pulls in the handle allocator needed to create the webSockets global (addressing #26310).

Changes:

  • Add an explicit dependency for emscripten_websocket_new to ensure required websocket runtime globals are generated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
},

emscripten_websocket_new__deps: ['$WS'],
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

emscripten_websocket_new only references the webSockets handle allocator (it doesn't use the WS helper object). Depending on $WS will also pull in malloc via $WS__deps, which can unnecessarily increase code size for minimal builds that only call emscripten_websocket_new. Consider changing this dependency to $webSockets (or otherwise avoid bringing in malloc) so the fix is minimal and directly matches what the function uses.

Suggested change
emscripten_websocket_new__deps: ['$WS'],
emscripten_websocket_new__deps: ['$webSockets'],

Copilot uses AI. Check for mistakes.
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
},

emscripten_websocket_new__deps: ['$WS'],
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

This fixes a missing dependency edge case (calling emscripten_websocket_new without any other websocket APIs). To prevent regressions, please consider adding a focused test that only links/calls emscripten_websocket_new (e.g., compile a tiny C program with -lwebsocket and run it) and asserts it doesn't throw ReferenceError: webSockets is not defined.

Suggested change
emscripten_websocket_new__deps: ['$WS'],
emscripten_websocket_new__deps: ['$WS', '$webSockets'],

Copilot uses AI. Check for mistakes.
@floooh
Copy link
Collaborator Author

floooh commented Feb 21, 2026

...does that Copilot suggestion even make sense? Please advice ;)

@sbc100
Copy link
Collaborator

sbc100 commented Feb 21, 2026

Yes, I actually think both those copolit suggestions are good .. I guess you are paying gopilot since I don't think I've seen it comment on emscripten PRs before.

@floooh
Copy link
Collaborator Author

floooh commented Feb 21, 2026

Hmm, weird, Copilot isn't active on my own projects and I don't remember haven't activated Copilot reviews or similar...

But anyway... I think the other PR at #26318 implements the same fix in a better way. Feel free to close my PR and merge the other one :)

@sbc100
Copy link
Collaborator

sbc100 commented Feb 21, 2026

I think the tricky part is likely adding a test, so whichever one of you if up for that we can land.

@sbc100
Copy link
Collaborator

sbc100 commented Feb 21, 2026

Closing in favor of #26318 i

@sbc100 sbc100 closed this Feb 21, 2026
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.

2 participants