Skip to content

Commit e4f48fe

Browse files
committed
quic: fix rejection of opened promise and add test
1 parent ed88355 commit e4f48fe

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎lib/internal/quic/quic.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ class QuicStream {
25862586
} else {
25872587
inner.pendingClose.resolve();
25882588
}
2589-
if (inner.pending) {
2589+
if (inner.state.pending) {
25902590
if (error !== undefined) {
25912591
inner.pendingStream.reject(error);
25922592
} else {

‎test/parallel/test-quic-stream-limits-pending.mjs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// and open when existing streams close.
77
// initialMaxStreamsUni limits concurrent uni streams (same behavior).
88

9-
import { hasQuic, skip, mustCall } from '../common/index.mjs';
9+
import { hasQuic, skip, mustCall, mustNotCall } from '../common/index.mjs';
1010
import assert from 'node:assert';
1111

1212
if (!hasQuic) {
@@ -61,6 +61,13 @@ s2.opened.then(() => {
6161
opened++;
6262
});
6363

64+
// Third stream is created but queued as pending because the
65+
// server only allows 1 concurrent bidi stream.
66+
const s3 = await clientSession.createBidirectionalStream({
67+
body: encoder.encode('stream 3'),
68+
});
69+
70+
6471
// s2 should be pending until s1 closes and the server grants
6572
// more stream credits.
6673
assert.strictEqual(s2.pending, true);
@@ -70,6 +77,12 @@ assert.strictEqual(opened, 1);
7077
for await (const _ of s1) { /* drain */ } // eslint-disable-line no-unused-vars
7178
await s1.closed;
7279

80+
const err = new Error('Test error');
81+
s3.destroy(err);
82+
83+
await assert.rejects(stream.closed, err);
84+
85+
7386
// After s1 closes, the server sends MAX_STREAMS which opens s2.
7487
// Wait for the server to receive both streams.
7588
await allDone.promise;

0 commit comments

Comments
 (0)