Skip to content

Conversation

@achingbrain
Copy link
Contributor

@achingbrain achingbrain commented Sep 17, 2025

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.

@achingbrain achingbrain changed the title test: recieve lots of data test: receive lots of data Sep 17, 2025
@achingbrain achingbrain force-pushed the test/receive-lots-of-data branch 2 times, most recently from 3b27b49 to 6bcc679 Compare September 17, 2025 16:32
@achingbrain
Copy link
Contributor Author

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

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 a bit slow.
@achingbrain achingbrain force-pushed the test/receive-lots-of-data branch from 6bcc679 to 46b17ae Compare September 18, 2025 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant