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
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1384,7 +1384,7 @@ class ClientHttp2Session extends Http2Session { |
1384 | 1384 |
|
1385 | 1385 | const onConnect = requestOnConnect.bind(stream, headersList, options); |
1386 | 1386 | if (this.connecting) { |
1387 | | - this.on('connect', onConnect); |
| 1387 | + this.once('connect', onConnect); |
1388 | 1388 | } else { |
1389 | 1389 | onConnect(); |
1390 | 1390 | } |
|
Collapse file
Copy file name to clipboard +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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 | +})); |