Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
fixup! fixup! debugger: fix event listener leak in the run command
  • Loading branch information
joyeecheung committed Nov 4, 2025
commit ccabb5270a815f14c4f982985e82c458c89e1b7a
25 changes: 5 additions & 20 deletions lib/internal/debugger/inspect_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
const Buffer = require('buffer').Buffer;
const crypto = require('crypto');
const { ERR_DEBUGGER_ERROR } = require('internal/errors').codes;
const { EventEmitter } = require('events');
const { EventEmitter, once } = require('events');
const http = require('http');
const { URL } = require('internal/url');

Expand Down Expand Up @@ -343,25 +343,10 @@ class Client extends EventEmitter {
this.emit('ready');
};

return new Promise((resolve, reject) => {
const tearDown = () => {
this.removeListener('ready', onReady);
this.removeListener('error', onError);
};
const onError = (err) => {
tearDown();
reject(err);
};
const onReady = () => {
tearDown();
resolve();
};
this.on('error', onError);
this.on('ready', onReady);

httpReq.on('upgrade', handshakeListener);
httpReq.end();
});
const onReady = once(this, 'ready');
httpReq.on('upgrade', handshakeListener);
httpReq.end();
return onReady;
}
}

Expand Down
Loading