node-datachannel
node-datachannel copied to clipboard
test: receive lots of data
Adds a test that opens a datachannel. When the remote receives notification of the new channel it writes lots of data into it and closes the channel. The local peer counts the received bytes and asserts that it received them all.
This test currently fails intermittently, largely down to the amount of load the process is under at the time.
You can run similar code in a browser here: https://codepen.io/achingbrain/pen/KwVPZBP?editors=0012
This works in Chrome and Firefox Nightly, though Firefox is quite slow, it takes about 12s for me vs 0.5s for Chrome.
You can run this test easily with until-death:
until-death npm test
For me it'll pass 2-3 times before failing:
% until-death npm test
> [email protected] test
> NODE_OPTIONS=--experimental-vm-modules jest
PASS test/jest-tests/basic.test.ts
PASS test/jest-tests/p2p.test.ts
PASS test/jest-tests/streams.test.ts
FAIL test/jest-tests/polyfill.test.ts
● polyfill › it should receive lots of data
expect(received).toEqual(expected) // deep equality
Expected: 10485760
Received: 10229760
379 | ]);
380 |
> 381 | expect(received).toEqual(bytes);
| ^
382 |
383 | peer1.close();
384 | peer2.close();
at Object.<anonymous> (test/jest-tests/polyfill.test.ts:381:22)
PASS test/jest-tests/websocket.test.ts
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
Test Suites: 1 failed, 4 passed, 5 total
Tests: 1 failed, 11 passed, 12 total
Snapshots: 0 total
Time: 4.467 s
Ran all test suites.
file:///Users/alex/.nvm/versions/node/v22.11.0/lib/node_modules/until-death/node_modules/execa/lib/error.js:60
error = new Error(message);
^
Error: Command failed with exit code 1: npm test
at makeError (file:///Users/alex/.nvm/versions/node/v22.11.0/lib/node_modules/until-death/node_modules/execa/lib/error.js:60:11)
at handlePromise (file:///Users/alex/.nvm/versions/node/v22.11.0/lib/node_modules/until-death/node_modules/execa/index.js:124:26)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///Users/alex/.nvm/versions/node/v22.11.0/lib/node_modules/until-death/index.js:10:3 {
shortMessage: 'Command failed with exit code 1: npm test',
command: 'npm test',
escapedCommand: 'npm test',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: undefined,
stderr: undefined,
cwd: '/Users/alex/Documents/Workspaces/murat-dogan/node-datachannel',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
Node.js v22.11.0