Skip to content

Commit

Permalink
http2: emit 'aborted' events instead of 'sessionError'
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Apr 22, 2020
1 parent c355430 commit ca0b8c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
16 changes: 0 additions & 16 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1710,14 +1710,6 @@ added: v8.4.0
The `'session'` event is emitted when a new `Http2Session` is created by the
`Http2Server`.

#### Event: `'sessionError'`
<!-- YAML
added: v8.4.0
-->

The `'sessionError'` event is emitted when an `'error'` event is emitted by
an `Http2Session` object associated with the `Http2Server`.

#### Event: `'stream'`
<!-- YAML
added: v8.4.0
Expand Down Expand Up @@ -1871,14 +1863,6 @@ added: v8.4.0
The `'session'` event is emitted when a new `Http2Session` is created by the
`Http2SecureServer`.

#### Event: `'sessionError'`
<!-- YAML
added: v8.4.0
-->

The `'sessionError'` event is emitted when an `'error'` event is emitted by
an `Http2Session` object associated with the `Http2SecureServer`.

#### Event: `'stream'`
<!-- YAML
added: v8.4.0
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2794,7 +2794,7 @@ function sessionOnPriority(stream, parent, weight, exclusive) {

function sessionOnError(error) {
if (this[kServer] !== undefined)
this[kServer].emit('sessionError', error, this);
this[kServer].emit('aborted', error, this);
}

// When the session times out on the server, try emitting a timeout event.
Expand Down
22 changes: 11 additions & 11 deletions test/parallel/test-http2-client-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,27 @@ const Countdown = require('../common/countdown');

req.on('response', common.mustNotCall());

const sessionError = {
const aborted = {
name: 'Error',
code: 'ERR_HTTP2_INVALID_SESSION',
message: 'The session has been destroyed'
};

assert.throws(() => client.setNextStreamID(), sessionError);
assert.throws(() => client.ping(), sessionError);
assert.throws(() => client.settings({}), sessionError);
assert.throws(() => client.goaway(), sessionError);
assert.throws(() => client.request(), sessionError);
assert.throws(() => client.setNextStreamID(), aborted);
assert.throws(() => client.ping(), aborted);
assert.throws(() => client.settings({}), aborted);
assert.throws(() => client.goaway(), aborted);
assert.throws(() => client.request(), aborted);
client.close(); // Should be a non-op at this point

// Wait for setImmediate call from destroy() to complete
// so that state.destroyed is set to true
setImmediate(() => {
assert.throws(() => client.setNextStreamID(), sessionError);
assert.throws(() => client.ping(), sessionError);
assert.throws(() => client.settings({}), sessionError);
assert.throws(() => client.goaway(), sessionError);
assert.throws(() => client.request(), sessionError);
assert.throws(() => client.setNextStreamID(), aborted);
assert.throws(() => client.ping(), aborted);
assert.throws(() => client.settings({}), aborted);
assert.throws(() => client.goaway(), aborted);
assert.throws(() => client.request(), aborted);
client.close(); // Should be a non-op at this point
});

Expand Down

0 comments on commit ca0b8c5

Please sign in to comment.