mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
before this PR, it was necessary to poll, if a stream can not be created immediately due to flow control. This PR adds a promise to QuicStream, that fulfills, when a stream is available and ready. Signed-off-by: Marten Richter <marten.richter@freenet.de> PR-URL: https://github.com/nodejs/node/pull/65862 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com>
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
// Flags: --expose-internals --experimental-quic --no-warnings
|
|
import { hasQuic, skip } from '../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
|
|
if (!hasQuic) {
|
|
skip('QUIC is not enabled');
|
|
}
|
|
|
|
import { default as binding } from 'internal/test/binding';
|
|
const quic = binding.internalBinding('quic');
|
|
|
|
const callbacks = {
|
|
onEndpointClose() {},
|
|
onSessionNew() {},
|
|
onSessionClose() {},
|
|
onSessionApplication() {},
|
|
onSessionDatagram() {},
|
|
onSessionDatagramStatus() {},
|
|
onSessionHandshake() {},
|
|
onSessionPathValidation() {},
|
|
onSessionTicket() {},
|
|
onSessionNewToken() {},
|
|
onSessionKeyLog() {},
|
|
onSessionQlog() {},
|
|
onSessionEarlyDataRejected() {},
|
|
onSessionOrigin() {},
|
|
onSessionGoaway() {},
|
|
onSessionVersionNegotiation() {},
|
|
onStreamAvailable() {},
|
|
onStreamCreated() {},
|
|
onStreamBlocked() {},
|
|
onStreamClose() {},
|
|
onStreamDrain() {},
|
|
onStreamReset() {},
|
|
onStreamStopSending() {},
|
|
onStreamHeaders() {},
|
|
onStreamTrailers() {},
|
|
};
|
|
// Fail if any callback is missing
|
|
for (const fn of Object.keys(callbacks)) {
|
|
// eslint-disable-next-line no-unused-vars
|
|
const { [fn]: _, ...rest } = callbacks;
|
|
assert.throws(() => quic.setCallbacks(rest), {
|
|
code: 'ERR_MISSING_ARGS',
|
|
});
|
|
}
|
|
// If all callbacks are present it should work
|
|
quic.setCallbacks(callbacks);
|
|
|
|
// Multiple calls should just be ignored.
|
|
quic.setCallbacks(callbacks);
|