Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
quic: fix rejection of opened promise and add test
  • Loading branch information
martenrichter committed Sep 9, 2026
commit dc01a8d76443ad419384875a13c19fb386b82ba4
2 changes: 1 addition & 1 deletion lib/internal/quic/quic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ class QuicStream {
} else {
inner.pendingClose.resolve();
}
if (inner.pending) {
if (inner.state.pending) {
if (error !== undefined) {
inner.pendingStream.reject(error);
} else {
Expand Down
15 changes: 14 additions & 1 deletion test/parallel/test-quic-stream-limits-pending.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// and open when existing streams close.
// initialMaxStreamsUni limits concurrent uni streams (same behavior).

import { hasQuic, skip, mustCall } from '../common/index.mjs';
import { hasQuic, skip, mustCall, mustNotCall } from '../common/index.mjs';
import assert from 'node:assert';

if (!hasQuic) {
Expand Down Expand Up @@ -61,6 +61,13 @@ s2.opened.then(() => {
opened++;
});

// Third stream is created but queued as pending because the
// server only allows 1 concurrent bidi stream.
const s3 = await clientSession.createBidirectionalStream({
body: encoder.encode('stream 3'),
});


// s2 should be pending until s1 closes and the server grants
// more stream credits.
assert.strictEqual(s2.pending, true);
Expand All @@ -70,6 +77,12 @@ assert.strictEqual(opened, 1);
for await (const _ of s1) { /* drain */ } // eslint-disable-line no-unused-vars
await s1.closed;

const err = new Error('Test error');
s3.destroy(err);

await assert.rejects(stream.closed, err);


// After s1 closes, the server sends MAX_STREAMS which opens s2.
// Wait for the server to receive both streams.
await allDone.promise;
Expand Down