@@ -5,7 +5,7 @@ const os = require('os')
55const { assert } = require ( 'chai' )
66const { pollInterval, setup } = require ( './utils' )
77const { assertObjectContains, assertUUID } = require ( '../helpers' )
8- const { ACKNOWLEDGED , ERROR } = require ( '../../packages/dd-trace/src/remote_config/apply_states' )
8+ const { UNACKNOWLEDGED , ACKNOWLEDGED , ERROR } = require ( '../../packages/dd-trace/src/remote_config/apply_states' )
99const { version } = require ( '../../package.json' )
1010
1111describe ( 'Dynamic Instrumentation' , function ( ) {
@@ -37,6 +37,10 @@ describe('Dynamic Instrumentation', function () {
3737 } ]
3838
3939 t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
40+ // Due to the very short DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, there's a race condition in which we might
41+ // get an UNACKNOWLEDGED state first before the ACKNOWLEDGED state.
42+ if ( state === UNACKNOWLEDGED ) return
43+
4044 assert . strictEqual ( id , t . rcConfig . id )
4145 assert . strictEqual ( version , 1 )
4246 assert . strictEqual ( state , ACKNOWLEDGED )
@@ -101,6 +105,10 @@ describe('Dynamic Instrumentation', function () {
101105 ]
102106
103107 t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
108+ // Due to the very short DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, there's a race condition in which we might
109+ // get an UNACKNOWLEDGED state first before the ACKNOWLEDGED state.
110+ if ( state === UNACKNOWLEDGED ) return
111+
104112 assert . strictEqual ( id , t . rcConfig . id )
105113 assert . strictEqual ( version , ++ receivedAckUpdates )
106114 assert . strictEqual ( state , ACKNOWLEDGED )
@@ -141,6 +149,10 @@ describe('Dynamic Instrumentation', function () {
141149 } ]
142150
143151 t . agent . on ( 'remote-config-ack-update' , ( id , version , state , error ) => {
152+ // Due to the very short DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, there's a race condition in which we might
153+ // get an UNACKNOWLEDGED state first before the ACKNOWLEDGED state.
154+ if ( state === UNACKNOWLEDGED ) return
155+
144156 assert . strictEqual ( id , t . rcConfig . id )
145157 assert . strictEqual ( version , 1 )
146158 assert . strictEqual ( state , ACKNOWLEDGED )
0 commit comments