Skip to content

Commit 9fa18bc

Browse files
committed
fix(collector): destroyed request on error or timeout
1 parent 379f926 commit 9fa18bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/collector/src/announceCycle/agentHostLookup.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ function checkHost(host, cb) {
173173
}
174174

175175
req.on('timeout', function onTimeout() {
176+
if (req.destroyed) {
177+
return;
178+
}
179+
180+
req.destroy();
176181
handleCallback(
177182
new Error(`The attempt to connect to the Instana host agent on ${host}:${agentOpts.port} has timed out`)
178183
);
@@ -182,6 +187,11 @@ function checkHost(host, cb) {
182187
req.setTimeout(requestTimeout);
183188

184189
req.on('error', err => {
190+
if (req.destroyed) {
191+
return;
192+
}
193+
194+
req.destroy();
185195
handleCallback(
186196
new Error(
187197
`The attempt to connect to the Instana host agent on ${host}:${agentOpts.port} has failed with the following ` +

0 commit comments

Comments
 (0)