GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: fix subsequent end calls to not throw · nodejs/node@b61220e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/http2
    • compat.js
  • test/parallel
    • test-http2-compat-serverresponse-end.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/http2/compat.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/compat.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,13 @@ class Http2ServerResponse extends Stream {
466466
cb = encoding;
467467
encoding = 'utf8';
468468
}
469+
if (stream === undefined || stream.finished === true) {
470+
return false;
471+
}
469472
if (chunk !== null && chunk !== undefined) {
470473
this.write(chunk, encoding);
471474
}
472475

473-
if (stream === undefined) {
474-
return;
475-
}
476-
477476
if (typeof cb === 'function') {
478477
stream.once('finish', cb);
479478
}
Collapse file

‎test/parallel/test-http2-compat-serverresponse-end.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-compat-serverresponse-end.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const { mustCall, mustNotCall, hasCrypto, skip } = require('../common');
55
if (!hasCrypto)
66
skip('missing crypto');
7-
const { strictEqual } = require('assert');
7+
const { doesNotThrow, strictEqual } = require('assert');
88
const {
99
createServer,
1010
connect,
@@ -19,6 +19,9 @@ const {
1919
// but may be invoked repeatedly without throwing errors.
2020
const server = createServer(mustCall((request, response) => {
2121
strictEqual(response.closed, false);
22+
response.on('finish', mustCall(() => process.nextTick(
23+
mustCall(() => doesNotThrow(() => response.end('test', mustNotCall())))
24+
)));
2225
response.end(mustCall(() => {
2326
server.close();
2427
}));

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.