Skip to content

Commit aa68f29

Browse files
authored
test(ci-vis): fix flaky agent-proxy test race (#7532)
The setUrl test didn't await _canUseCiVisProtocolPromise, leaving an in-flight fetchAgentInfo callback that could fire after the next beforeEach's clearCache(), polluting the module-level cache with stale /info data. This caused _isGzipCompatible to intermittently read cached v2-only endpoints instead of the test's own v4+ nock response. Await the promise in the setUrl test and add nock.abortPendingRequests() to beforeEach as an additional safeguard against leaked in-flight responses.
1 parent 774492e commit aa68f29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/dd-trace/test/ci-visibility/exporters/agent-proxy/agent-proxy.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ const { clearCache } = require('../../../../src/agent/info')
1818

1919
describe('AgentProxyCiVisibilityExporter', () => {
2020
beforeEach(() => {
21-
clearCache()
21+
nock.abortPendingRequests()
2222
nock.cleanAll()
23+
clearCache()
2324
})
2425

2526
const flushInterval = 50
@@ -300,7 +301,7 @@ describe('AgentProxyCiVisibilityExporter', () => {
300301
})
301302

302303
describe('setUrl', () => {
303-
it('should set the URL on self and writers', () => {
304+
it('should set the URL on self and writers', async () => {
304305
const mockWriter = {
305306
setUrl: sinon.spy(),
306307
}
@@ -313,6 +314,7 @@ describe('AgentProxyCiVisibilityExporter', () => {
313314
endpoints: ['/evp_proxy/v2/'],
314315
}))
315316
const agentProxyCiVisibilityExporter = new AgentProxyCiVisibilityExporter({ port, tags })
317+
await agentProxyCiVisibilityExporter._canUseCiVisProtocolPromise
316318
agentProxyCiVisibilityExporter._writer = mockWriter
317319
agentProxyCiVisibilityExporter._coverageWriter = mockCoverageWriter
318320

0 commit comments

Comments
 (0)