@@ -58,6 +58,26 @@ describe('invokeOrchestrionInstrumentation', () => {
5858 expect ( client . listenerCount ( ) ) . toBe ( 0 ) ;
5959 } ) ;
6060
61+ it ( 'does not mark the callback when the binding never becomes available, so a later attempt recovers' , async ( ) => {
62+ GLOBAL_OBJ . __SENTRY_ORCHESTRION__ = { runtime : [ 'mysql' ] } ;
63+ // No async-context strategy, so `waitForTracingChannelBinding` finds no binding and gives up.
64+ setAsyncContextStrategy ( undefined ) ;
65+ const client = makeClient ( ) ;
66+ const callback = vi . fn ( ) ;
67+
68+ invokeOrchestrionInstrumentation ( client as never , [ 'mysql' ] , callback , [ ] ) ;
69+
70+ // Wait past `waitForTracingChannelBinding`'s single ~1ms retry; it bails without subscribing.
71+ await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
72+ expect ( callback ) . not . toHaveBeenCalled ( ) ;
73+
74+ // The callback must NOT have been marked as instrumented — once the binding exists, a later
75+ // invocation subscribes rather than being permanently skipped.
76+ installBinding ( ) ;
77+ invokeOrchestrionInstrumentation ( client as never , [ 'mysql' ] , callback , [ ] ) ;
78+ expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
79+ } ) ;
80+
6181 it ( 'does not subscribe until the module is injected at runtime' , ( ) => {
6282 const client = makeClient ( ) ;
6383 const callback = vi . fn ( ) ;
0 commit comments