Skip to content

Commit c820334

Browse files
authored
test(agent): fix dead double-send in handleTraceRequest (#7725)
When the test agent returned a non-200 status, handleTraceRequest attempted to call res.status(400).send() — but res.status(200).send() had already been called synchronously earlier in the same function, so the error response was silently dropped. Replace with a console.warn so test agent errors are visible in CI logs instead of swallowed. The res._closed guard is also removed since it only existed to protect the now-removed res.status(400) call.
1 parent d35deec commit c820334

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

packages/dd-trace/test/plugins/agent.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,15 @@ function handleTraceRequest (req, res, sendToTestAgent) {
200200
})
201201

202202
testAgentReq.on('response', testAgentRes => {
203-
if (res._closed) {
204-
// Skip handling for already closed agents
205-
return
206-
}
207-
208203
if (testAgentRes.statusCode !== 200) {
209204
// handle request failures from the Test Agent here
210205
let body = ''
211206
testAgentRes.on('data', chunk => {
212207
body += chunk
213208
})
214209
testAgentRes.on('end', () => {
215-
res.status(400).send(body)
210+
// eslint-disable-next-line no-console
211+
console.warn(`handleTraceRequest: Test agent returned ${testAgentRes.statusCode}: ${body}`)
216212
})
217213
}
218214
})

0 commit comments

Comments
 (0)