Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 2 additions & 17 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2138,23 +2138,8 @@ const setTimeout = {
return this;
}
};

const onTimeout = {
configurable: false,
enumerable: false,
value: function() {
process.nextTick(emit.bind(this, 'timeout'));
}
};

Object.defineProperties(Http2Stream.prototype, {
setTimeout,
onTimeout
});
Object.defineProperties(Http2Session.prototype, {
setTimeout,
onTimeout
});
Object.defineProperty(Http2Stream.prototype, 'setTimeout', setTimeout);
Object.defineProperty(Http2Session.prototype, 'setTimeout', setTimeout);

// --------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http2-server-startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ assert.doesNotThrow(() => {
if (client)
client.end();
}));
server.setTimeout(common.platformTimeout(1000));
server.setTimeout(common.platformTimeout(1000), common.mustCall());
server.listen(0, common.mustCall(() => {
const port = server.address().port;
client = net.connect(port, common.mustCall());
Expand All @@ -70,7 +70,7 @@ assert.doesNotThrow(() => {
if (client)
client.end();
}));
server.setTimeout(common.platformTimeout(1000));
server.setTimeout(common.platformTimeout(1000), common.mustCall());
server.listen(0, common.mustCall(() => {
const port = server.address().port;
client = tls.connect({
Expand Down
26 changes: 26 additions & 0 deletions test/parallel/test-http2-timeouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ server.on('stream', common.mustCall((stream) => {
stream.respond({ ':status': 200 });
stream.end('hello world');
}));

// check that expected errors are thrown with wrong args
common.expectsError(
() => stream.setTimeout('100'),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "msecs" argument must be of type number'
}
);
common.expectsError(
() => stream.setTimeout(0, Symbol('test')),
{
code: 'ERR_INVALID_CALLBACK',
type: TypeError,
message: 'Callback must be a function'
}
);
common.expectsError(
() => stream.setTimeout(100, {}),
{
code: 'ERR_INVALID_CALLBACK',
type: TypeError,
message: 'Callback must be a function'
}
);
}));
server.listen(0);

Expand Down