-
Notifications
You must be signed in to change notification settings - Fork 540
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
WebSockets #1811
Comments
Hmm, would that be really be any good? |
No, but it's the only way that issue could be fixed without adding complexity. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Implementing a server is definitely out of scope: use |
What would it take to maybe say: Build a own npm package that depends on undici WebSocket and tries to build a compatible server? would it be even at all possible by using I'm guessing it would have to work quite differently if you used http/1/2/3 quick WebTransport or whatever is the new "thing"
I bet so too. Guess ppl are going to ask about this when they learn that there is a built in WebSocket later |
Is there any update on the "Setting an undici Dispatcher rather than using the global dispatcher by default." feature? I need to send each WebSocket to different targets without modifying the const agent = new Agent({
factory(origin, opts) {
const pool = new Pool(origin, {
...opts,
factory(origin, opts) {
const client = new Client(origin, opts);
// Remote debugging validates `Host` header to defend against DNS rebinding attacks.
// But we can only pass socket name using hostname, so we need to override it.
(client as any)[Symbols.kHostHeader] = "Host: localhost\r\n";
return client;
},
});
return pool;
},
async connect(options, callback) {
try {
const socket = await device.createSocket(
"localabstract:" + options.hostname
);
callback(null, new AdbUndiciSocket(socket) as unknown as Socket);
} catch (e) {
callback(e as Error, null);
}
},
});
// WebSocket only uses global dispatcher
setGlobalDispatcher(agent); I'm also concerned that undici used in other libraries will also be affected by my global dispatcher. |
Yes, I'm planning on implementing my proposal which will allow us to do so. I should have a PR in the next day, if I remember. |
* websocket: add websocketinit Refs: #1811 (comment) * update types * remove 3rd param it's not as backwards compatible as I thought... * update docs
* websocket: add websocketinit Refs: nodejs#1811 (comment) * update types * remove 3rd param it's not as backwards compatible as I thought... * update docs
* websocket: add websocketinit Refs: nodejs#1811 (comment) * update types * remove 3rd param it's not as backwards compatible as I thought... * update docs
permessage-deflate
supportPerformance
Consume the least amount of bytes possible, rather than concatenating every chunk available. See ws' implementation.Fixed in 5165d67Switch to Buffer.allocUnsafe inFixed in b6844f0lib/websocket/frame.js
Handle TODO comments labeled as "optimize this".Use FastBuffer (Buffer[Symbol.species]
)Tests
Add ws' test suite. Note this isn't easy because ws' api does not strictly follow the spec and it occasionally uses internal, underscored properties. Also note that a lot of the validation tests are already handled by the WPTs.Autobahn testsuite100% code coverage for lib/websocketsCode coverage is high enough; WPTs are not counted, which make up a majority of the tests.Test more strange/error conditions:Chunks that contain thousands of framesChunks that receive a pong/close frame in the middle of a fragmented message(Control frames are already handled the same.)Sending invalid framesBugs
WebSocket.send
with a Blob asynchronously writes the blob data to the socket. This can cause issues when concurrently sending a blob with anything else. Note: we need support in node core to read a Blob synchronously.Fixed in 1b858fbByteParser.run
runs recursively, meaning the max call stack can be exceeded under certain conditions (ie. receiving thousands of frames in a single chunk).Features
Setting an undici Dispatcher rather than using the global dispatcher by default.WebSocketStream
The text was updated successfully, but these errors were encountered: