Skip to content

Commit 83bf0d7

Browse files
committed
quic: remove unneeded quicstream.aborted and fixup docs
PR-URL: #34351 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent a65296d commit 83bf0d7

File tree

3 files changed

+13
-46
lines changed

3 files changed

+13
-46
lines changed

doc/api/quic.md

+11-33
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,9 @@ const { createQuicSocket } = require('net');
2525
// Create the QUIC UDP IPv4 socket bound to local IP port 1234
2626
const socket = createQuicSocket({ endpoint: { port: 1234 } });
2727

28-
socket.on('session', (session) => {
28+
socket.on('session', async (session) => {
2929
// A new server side session has been created!
3030

31-
session.on('secure', () => {
32-
// Once the TLS handshake is completed, we can
33-
// open streams...
34-
const uni = session.openStream({ halfOpen: true });
35-
uni.write('hi ');
36-
uni.end('from the server!');
37-
});
38-
3931
// The peer opened a new stream!
4032
session.on('stream', (stream) => {
4133
// Let's say hello
@@ -46,6 +38,10 @@ socket.on('session', (session) => {
4638
stream.on('data', console.log);
4739
stream.on('end', () => console.log('stream ended'));
4840
});
41+
42+
const uni = await session.openStream({ halfOpen: true });
43+
uni.write('hi ');
44+
uni.end('from the server!');
4945
});
5046

5147
// Tell the socket to operate as a server using the given
@@ -187,10 +183,10 @@ The `openStream()` method is used to create a new `QuicStream`:
187183

188184
```js
189185
// Create a new bidirectional stream
190-
const stream1 = session.openStream();
186+
const stream1 = await session.openStream();
191187

192188
// Create a new unidirectional stream
193-
const stream2 = session.openStream({ halfOpen: true });
189+
const stream2 = await session.openStream({ halfOpen: true });
194190
```
195191

196192
As suggested by the names, a bidirectional stream allows data to be sent on
@@ -1045,12 +1041,12 @@ added: REPLACEME
10451041
* `defaultEncoding` {string} The default encoding that is used when no
10461042
encoding is specified as an argument to `quicstream.write()`. Default:
10471043
`'utf8'`.
1048-
* Returns: {QuicStream}
1044+
* Returns: {Promise} containing {QuicStream}
10491045

1050-
Returns a new `QuicStream`.
1046+
Returns a `Promise` that resolves a new `QuicStream`.
10511047

1052-
An error will be thrown if the `QuicSession` has been destroyed or is in the
1053-
process of a graceful shutdown.
1048+
The `Promise` will be rejected if the `QuicSession` has been destroyed or is in
1049+
the process of a graceful shutdown.
10541050

10551051
#### `quicsession.ping()`
10561052
<!--YAML
@@ -2153,14 +2149,6 @@ stream('trailingHeaders', (headers) => {
21532149
added: REPLACEME
21542150
-->
21552151

2156-
#### `quicstream.aborted`
2157-
<!-- YAML
2158-
added: REPLACEME
2159-
-->
2160-
* Type: {boolean}
2161-
2162-
True if dataflow on the `QuicStream` was prematurely terminated.
2163-
21642152
#### `quicstream.bidirectional`
21652153
<!--YAML
21662154
added: REPLACEME
@@ -2281,16 +2269,6 @@ added: REPLACEME
22812269

22822270
The maximum received offset for this `QuicStream`.
22832271

2284-
#### `quicstream.pending`
2285-
<!-- YAML
2286-
added: REPLACEME
2287-
-->
2288-
2289-
* {boolean}
2290-
2291-
This property is `true` if the underlying session is not finished yet,
2292-
i.e. before the `'ready'` event is emitted.
2293-
22942272
#### `quicstream.pushStream(headers\[, options\])`
22952273
<!-- YAML
22962274
added: REPLACEME

lib/internal/quic/core.js

-7
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,6 @@ function streamOnPause() {
25342534
class QuicStream extends Duplex {
25352535
[kInternalState] = {
25362536
closed: false,
2537-
aborted: false,
25382537
defaultEncoding: undefined,
25392538
didRead: false,
25402539
id: undefined,
@@ -2653,8 +2652,6 @@ class QuicStream extends Duplex {
26532652

26542653
state.closed = true;
26552654

2656-
state.aborted = this.readable || this.writable;
2657-
26582655
// Trigger scheduling of the RESET_STREAM and STOP_SENDING frames
26592656
// as appropriate. Notify ngtcp2 that the stream is to be shutdown.
26602657
// Once sent, the stream will be closed and destroyed as soon as
@@ -2702,10 +2699,6 @@ class QuicStream extends Duplex {
27022699
// TODO(@jasnell): Implement this later
27032700
}
27042701

2705-
get aborted() {
2706-
return this[kInternalState].aborted;
2707-
}
2708-
27092702
get serverInitiated() {
27102703
return !!(this[kInternalState].id & 0b01);
27112704
}

test/parallel/test-quic-quicstream-close-early.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ const countdown = new Countdown(2, () => {
2525
server.on('session', common.mustCall(async (session) => {
2626
const uni = await session.openStream({ halfOpen: true });
2727
uni.write('hi', common.expectsError());
28-
uni.on('error', common.mustCall(() => {
29-
assert.strictEqual(uni.aborted, true);
30-
}));
28+
uni.on('error', common.mustCall());
3129
uni.on('data', common.mustNotCall());
3230
uni.on('close', common.mustCall());
3331
uni.close(3);
@@ -56,9 +54,7 @@ const countdown = new Countdown(2, () => {
5654
const stream = await req.openStream();
5755
stream.write('hello', common.expectsError());
5856
stream.write('there', common.expectsError());
59-
stream.on('error', common.mustCall(() => {
60-
assert.strictEqual(stream.aborted, true);
61-
}));
57+
stream.on('error', common.mustCall());
6258
stream.on('end', common.mustNotCall());
6359
stream.on('close', common.mustCall(() => {
6460
countdown.dec();

0 commit comments

Comments
 (0)