-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
net: do not add multiple connect and finish listeners when multiple Socket.destroySoon's were scheduled
#60469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
6e33069
9905cfb
afe8307
565e2c2
94edac0
e5ec2a4
ae5739e
a70ef63
a63fb37
40ef455
c2e85a0
3d238a0
81ac752
f703403
7b5a01a
c9a2c5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| 'use strict'; | ||
| require('../common'); | ||
| const { addresses } = require('../common/internet'); | ||
|
|
||
| const assert = require('assert'); | ||
| const net = require('net'); | ||
|
|
||
| const socket = new net.Socket(); | ||
| socket.on('error', () => { | ||
| // noop | ||
| }); | ||
| const connectOptions = { host: addresses.INVALID_HOST, port: 1234 }; | ||
|
|
||
| socket.connect(connectOptions); | ||
| socket.destroySoon(); // Adds "connect" and "finish" event listeners when socket has "writable" state | ||
| socket.destroy(); // Makes imideditly socket again "writable" | ||
|
|
||
| socket.connect(connectOptions); | ||
|
||
| socket.destroySoon(); // Should not duplicate "connect" and "finish" event listeners | ||
|
|
||
| assert.strictEqual(socket.listeners('finish').length, 1); | ||
| assert.strictEqual(socket.listeners('connect').length, 1); | ||
Uh oh!
There was an error while loading. Please reload this page.