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
18 changes: 8 additions & 10 deletions src/lib/libsockfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,13 @@ addToLibrary({
#if SOCKET_DEBUG
dbg(`websocket: connect: ${url}, ${subProtocols.toString()}`);
#endif
// If node we use the ws library.
var WebSocketConstructor;
#if ENVIRONMENT_MAY_BE_NODE
if (ENVIRONMENT_IS_NODE) {
WebSocketConstructor = /** @type{(typeof WebSocket)} */(require('ws'));
} else
#endif // ENVIRONMENT_MAY_BE_NODE
{
WebSocketConstructor = WebSocket;
// If node we use the ws library.
if (ENVIRONMENT_IS_NODE && !globalThis.WebSocket) {
globalThis.WebSocket = /** @type{(typeof WebSocket)} */(require('ws'));
}
ws = new WebSocketConstructor(url, opts);
#endif // ENVIRONMENT_MAY_BE_NODE
ws = new WebSocket(url, opts);
ws.binaryType = 'arraybuffer';
} catch (e) {
#if SOCKET_DEBUG
Expand Down Expand Up @@ -515,10 +511,12 @@ addToLibrary({
sock.connecting = true;
},
listen(sock, backlog) {
#if !ENVIRONMENT_MAY_BE_NODE
throw new FS.ErrnoError({{{ cDefs.EOPNOTSUPP }}});
#else
if (!ENVIRONMENT_IS_NODE) {
throw new FS.ErrnoError({{{ cDefs.EOPNOTSUPP }}});
}
#if ENVIRONMENT_MAY_BE_NODE
if (sock.server) {
throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); // already listening
}
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 244343,
"a.out.js": 244388,
"a.out.nodebug.wasm": 577478,
"total": 821821,
"total": 821866,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
Loading