Initial curated chimera source from a8ae5b1db07fb49926c94585e2718e5130330974
This commit is contained in:
commit
c737a37f71
531 files changed
+119270
No files matched your search
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const WebSocket = require('ws');
|
||||
const { broadcastToSockets } = require('../../src/server/app-server');
|
||||
|
||||
test('broadcast closes slow websocket clients without blocking healthy clients', () => {
|
||||
const sent = [];
|
||||
const closed = [];
|
||||
const healthy = { readyState: WebSocket.OPEN, bufferedAmount: 0, send: message => sent.push(message) };
|
||||
const slow = { readyState: WebSocket.OPEN, bufferedAmount: 2048, send: () => assert.fail('slow client must not receive'), close: (code, reason) => closed.push({ code, reason }) };
|
||||
|
||||
const outcome = broadcastToSockets(new Set([healthy, slow]), '{"status":"ok"}', { maxBufferedBytes: 1024 });
|
||||
assert.deepEqual(outcome, { sent: 1, closed: 1 });
|
||||
assert.deepEqual(sent, ['{"status":"ok"}']);
|
||||
assert.equal(closed[0].code, 1008);
|
||||
});
|
||||
Reference in new issue
Block a user