-
Notifications
You must be signed in to change notification settings - Fork 563
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
feat: implement WebSocketStream #3560
Conversation
1c931a2
to
deae218
Compare
58d5072
to
1237174
Compare
@nodejs/undici This passes the same subset of WebSocketStream tests that Deno passes. It's missing types and docs now. Looking for code reviews before doing the trivial stuff. |
try { | ||
string = webidl.converters.USVString(chunk) | ||
} catch (e) { | ||
return Promise.reject(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldnt we reuse the already created deferred promise?
return promise.reject(e)
?
A limitation of cjs - there isn't much we can do about shared webidl declarations. If we moved them to webidl.js, we'd have circular imports, if we move them to another file, we have to import another file. |
return | ||
} | ||
} else if (type === opcodes.BINARY) { | ||
chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chunk = new Uint8Array(data.buffer, data.byteOffset, data.byteLength) | |
chunk = data.byteLength === data.buffer.byteLength ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data) |
Copy buffer if needed.
please approve so I can land... nits can wait, this is experimental I want to make websocket PRs but I don't want to manage multiple branches at once. ty |
With better-organized internals, this is now much easier and almost completely detached from WebSocket. I could rewrite it to be completely independent of WebSocket, which would allow us to remove it at any time (the only shared internals are a new
getURLRecord
function and the closing logic).