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: release request()'s "connect" event listener after it runs · nodejs/node@d602c7a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/http2
    • core.js
  • test/parallel
    • test-http2-request-remove-connect-listener.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ class ClientHttp2Session extends Http2Session {
13841384

13851385
const onConnect = requestOnConnect.bind(stream, headersList, options);
13861386
if (this.connecting) {
1387-
this.on('connect', onConnect);
1387+
this.once('connect', onConnect);
13881388
} else {
13891389
onConnect();
13901390
}
Collapse file

‎test/parallel/test-http2-request-remove-connect-listener.js‎

Copy file name to clipboard
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const assert = require('assert');
7+
const http2 = require('http2');
8+
9+
10+
const server = http2.createServer();
11+
server.on('stream', common.mustCall((stream) => {
12+
stream.respond();
13+
stream.end();
14+
}));
15+
16+
server.listen(0, common.mustCall(() => {
17+
const client = http2.connect(`http://localhost:${server.address().port}`);
18+
const req = client.request();
19+
client.once('connect', common.mustCall());
20+
21+
req.on('response', common.mustCall(() => {
22+
assert.strictEqual(client.listenerCount('connect'), 0);
23+
}));
24+
req.on('close', common.mustCall(() => {
25+
server.close();
26+
client.close();
27+
}));
28+
}));

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.