Skip to content

Commit

Permalink
quic: remove unneeded quicstream.aborted and fixup docs
Browse files Browse the repository at this point in the history
PR-URL: #34351
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
jasnell committed Jul 23, 2020
1 parent a65296d commit 83bf0d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 46 deletions.
44 changes: 11 additions & 33 deletions doc/api/quic.md
Expand Up @@ -25,17 +25,9 @@ const { createQuicSocket } = require('net');
// Create the QUIC UDP IPv4 socket bound to local IP port 1234
const socket = createQuicSocket({ endpoint: { port: 1234 } });

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

session.on('secure', () => {
// Once the TLS handshake is completed, we can
// open streams...
const uni = session.openStream({ halfOpen: true });
uni.write('hi ');
uni.end('from the server!');
});

// The peer opened a new stream!
session.on('stream', (stream) => {
// Let's say hello
Expand All @@ -46,6 +38,10 @@ socket.on('session', (session) => {
stream.on('data', console.log);
stream.on('end', () => console.log('stream ended'));
});

const uni = await session.openStream({ halfOpen: true });
uni.write('hi ');
uni.end('from the server!');
});

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

```js
// Create a new bidirectional stream
const stream1 = session.openStream();
const stream1 = await session.openStream();

// Create a new unidirectional stream
const stream2 = session.openStream({ halfOpen: true });
const stream2 = await session.openStream({ halfOpen: true });
```

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

Returns a new `QuicStream`.
Returns a `Promise` that resolves a new `QuicStream`.

An error will be thrown if the `QuicSession` has been destroyed or is in the
process of a graceful shutdown.
The `Promise` will be rejected if the `QuicSession` has been destroyed or is in
the process of a graceful shutdown.

#### `quicsession.ping()`
<!--YAML
Expand Down Expand Up @@ -2153,14 +2149,6 @@ stream('trailingHeaders', (headers) => {
added: REPLACEME
-->

#### `quicstream.aborted`
<!-- YAML
added: REPLACEME
-->
* Type: {boolean}

True if dataflow on the `QuicStream` was prematurely terminated.

#### `quicstream.bidirectional`
<!--YAML
added: REPLACEME
Expand Down Expand Up @@ -2281,16 +2269,6 @@ added: REPLACEME

The maximum received offset for this `QuicStream`.

#### `quicstream.pending`
<!-- YAML
added: REPLACEME
-->

* {boolean}

This property is `true` if the underlying session is not finished yet,
i.e. before the `'ready'` event is emitted.

#### `quicstream.pushStream(headers\[, options\])`
<!-- YAML
added: REPLACEME
Expand Down
7 changes: 0 additions & 7 deletions lib/internal/quic/core.js
Expand Up @@ -2534,7 +2534,6 @@ function streamOnPause() {
class QuicStream extends Duplex {
[kInternalState] = {
closed: false,
aborted: false,
defaultEncoding: undefined,
didRead: false,
id: undefined,
Expand Down Expand Up @@ -2653,8 +2652,6 @@ class QuicStream extends Duplex {

state.closed = true;

state.aborted = this.readable || this.writable;

// Trigger scheduling of the RESET_STREAM and STOP_SENDING frames
// as appropriate. Notify ngtcp2 that the stream is to be shutdown.
// Once sent, the stream will be closed and destroyed as soon as
Expand Down Expand Up @@ -2702,10 +2699,6 @@ class QuicStream extends Duplex {
// TODO(@jasnell): Implement this later
}

get aborted() {
return this[kInternalState].aborted;
}

get serverInitiated() {
return !!(this[kInternalState].id & 0b01);
}
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-quic-quicstream-close-early.js
Expand Up @@ -25,9 +25,7 @@ const countdown = new Countdown(2, () => {
server.on('session', common.mustCall(async (session) => {
const uni = await session.openStream({ halfOpen: true });
uni.write('hi', common.expectsError());
uni.on('error', common.mustCall(() => {
assert.strictEqual(uni.aborted, true);
}));
uni.on('error', common.mustCall());
uni.on('data', common.mustNotCall());
uni.on('close', common.mustCall());
uni.close(3);
Expand Down Expand Up @@ -56,9 +54,7 @@ const countdown = new Countdown(2, () => {
const stream = await req.openStream();
stream.write('hello', common.expectsError());
stream.write('there', common.expectsError());
stream.on('error', common.mustCall(() => {
assert.strictEqual(stream.aborted, true);
}));
stream.on('error', common.mustCall());
stream.on('end', common.mustNotCall());
stream.on('close', common.mustCall(() => {
countdown.dec();
Expand Down

0 comments on commit 83bf0d7

Please sign in to comment.