Skip to content
Closed
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: remove unneeded quicstream.aborted and fixup docs
  • Loading branch information
jasnell committed Jul 23, 2020
commit 21a96cb9feb6028311279fbd1ec070d67e234130
44 changes: 11 additions & 33 deletions doc/api/quic.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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