Skip to content

Commit abcec71

Browse files
committed
quic: Fix badly rebased test
1 parent 414dd97 commit abcec71

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ let serverStreamCount = 0;
2525
// Server allows only 1 bidi stream at a time.
2626
const serverEndpoint = await listen(mustCall((serverSession) => {
2727
serverSession.onstream = mustCall(async (stream) => {
28-
console.log("server mark 1")
2928
await bytes(stream);
30-
console.log("server mark 2")
3129
stream.writer.endSync();
32-
console.log("server mark 3")
3330
await stream.closed;
3431
++serverStreamCount;
35-
console.log('serverStreamCount', serverStreamCount)
3632
if (serverStreamCount === 2) {
3733
twoDone.resolve();
3834
}
@@ -62,11 +58,12 @@ s1.opened.then(() => {
6258
opened++;
6359
});
6460

61+
let s2;
6562
await assert.rejects(
6663
async () => {
6764
// Second stream should not open, but throw.
68-
await clientSession.createBidirectionalStream({
69-
body: encoder.encode('stream 2'),
65+
s2 = await clientSession.createBidirectionalStream({
66+
body: encoder.encode('stream 2a'),
7067
waitUntilAvailable: false,
7168
});
7269
// eslint-disable-next-line node-core/must-call-assert
@@ -79,13 +76,26 @@ await assert.rejects(
7976
message: 'No new stream available within flow control',
8077
},
8178
);
79+
// Ok try again a second second stream, that patiently waits
80+
s2 = await clientSession.createBidirectionalStream({
81+
body: encoder.encode('stream 2b')
82+
});
83+
// eslint-disable-next-line node-core/must-call-assert
84+
s2.opened.then(() => {
85+
opened++;
86+
});
87+
88+
8289
// Third stream is created but queued as pending because the
8390
// server only allows 1 concurrent bidi stream.
8491
const s3 = await clientSession.createBidirectionalStream({
8592
body: encoder.encode('stream 3'),
8693
});
87-
// Note, s3 should be pending until s1 closes and the server grants
94+
95+
96+
// s2 and s3 should be pending until s1 closes and the server grants
8897
// more stream credits.
98+
assert.strictEqual(s2.pending, true);
8999
assert.strictEqual(s3.pending, true);
90100
assert.strictEqual(opened, 1);
91101

@@ -98,13 +108,12 @@ s3.destroy(err);
98108

99109
await Promise.all([assert.rejects(s3.opened, err), assert.rejects(s3.closed, err)]);
100110

101-
// After s1 closes, the server sends MAX_STREAMS which opens s2.
111+
// After s1 closes, the server sends MAX_STREAMS which opens s3.
102112
// Wait for the server to receive both streams.
103113
await twoDone.promise;
104-
assert.strictEqual(opened, 2);
105-
// s3 should no longer be pending.
106-
for await (const _ of s3) { /* drain */ } // eslint-disable-line no-unused-vars
107-
await s3.closed;
114+
// s2 should no longer be pending.
115+
for await (const _ of s2) { /* drain */ } // eslint-disable-line no-unused-vars
116+
await s2.closed;
108117

109118
await sleep(10); // We wait a bit, as we do not have a callback exposed to js
110119
// fourth stream should open immediately and not throw
@@ -115,4 +124,4 @@ const s4 = await clientSession.createBidirectionalStream({
115124
await Promise.all([s4.closed, allDone.promise]);
116125

117126
await clientSession.close();
118-
await serverEndpoint.close();
127+
await serverEndpoint.close();

0 commit comments

Comments
 (0)