Commit e12c195
authored
fix(ci-visibility): fix race condition in agent-proxy exporter (#7375)
Fixes a race condition in AgentProxyCiVisibilityExporter where
`_isGzipCompatible` and `evpProxyPrefix` could be read before
being set, causing intermittent test failures in CI.
The race condition was amplified by commit 6eed53f which added
caching to fetchAgentInfo. When the cache is hit, the callback
runs via process.nextTick (extremely fast), making the timing
window between promise resolution and property assignment visible.
Production code fix:
- Move `this._isGzipCompatible = isGzipCompatible` to execute
before `this._resolveCanUseCiVisProtocol()` in the callback
- This ensures the property is set before tests (or production
code) can read it after awaiting `_canUseCiVisProtocolPromise`
- Matches the pattern in AgentlessCiVisibilityExporter
Test cleanup fix:
- Add `nock.cleanAll()` to beforeEach hook to prevent HTTP mock
state leakage between tests
- Without cleanup, nock interceptors from previous tests could
interfere with subsequent tests
- Follows the pattern in exporter.spec.js and other test files
Fixes 4 flaky tests:
- _isGzipCompatible (v4+ and v3 version checks)
- evpProxyPrefix (v2 and v4 prefix assignments)1 parent a2ff667 commit e12c195
File tree
2 files changed
+2
-2
lines changed- packages/dd-trace
- src/ci-visibility/exporters/agent-proxy
- test/ci-visibility/exporters/agent-proxy
2 files changed
+2
-2
lines changedLines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
0 commit comments