@@ -68,29 +68,35 @@ export class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
6868 return
6969 }
7070
71- if ( this . #providerCalled) {
72- // After changing providers, `clearTimeout` will not work as expected for
73- // timeouts from the previous provider.
74- //
75- // Since they may allocate the same timeout ID, clearTimeout may cancel an
76- // arbitrary different timeout, or unexpected no-op.
77- //
78- // We could protect against this by mixing the timeout ID bits
79- // deterministically with some per-provider bits.
80- //
81- // We could internally queue `setTimeout` calls to `TimeoutManager` until
82- // some API call to set the initial provider.
83- console . warn (
84- `[timeoutManager]: Switching to ${ provider . name } provider after calls to ${ this . #provider. name } provider might result in unexpected behavior.` ,
85- )
71+ if ( process . env . NODE_ENV !== 'production' ) {
72+ if ( this . #providerCalled) {
73+ // After changing providers, `clearTimeout` will not work as expected for
74+ // timeouts from the previous provider.
75+ //
76+ // Since they may allocate the same timeout ID, clearTimeout may cancel an
77+ // arbitrary different timeout, or unexpected no-op.
78+ //
79+ // We could protect against this by mixing the timeout ID bits
80+ // deterministically with some per-provider bits.
81+ //
82+ // We could internally queue `setTimeout` calls to `TimeoutManager` until
83+ // some API call to set the initial provider.
84+ console . error (
85+ `[timeoutManager]: Switching to ${ provider . name } provider after calls to ${ this . #provider. name } provider might result in unexpected behavior.` ,
86+ )
87+ }
8688 }
8789
8890 this . #provider = provider
89- this . #providerCalled = false
91+ if ( process . env . NODE_ENV !== 'production' ) {
92+ this . #providerCalled = false
93+ }
9094 }
9195
9296 setTimeout ( callback : TimeoutCallback , delay : number ) : ManagedTimerId {
93- this . #providerCalled = true
97+ if ( process . env . NODE_ENV !== 'production' ) {
98+ this . #providerCalled = true
99+ }
94100 return providerIdToNumber (
95101 this . #provider,
96102 this . #provider. setTimeout ( callback , delay ) ,
@@ -102,7 +108,9 @@ export class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
102108 }
103109
104110 setInterval ( callback : TimeoutCallback , delay : number ) : ManagedTimerId {
105- this . #providerCalled = true
111+ if ( process . env . NODE_ENV !== 'production' ) {
112+ this . #providerCalled = true
113+ }
106114 return providerIdToNumber (
107115 this . #provider,
108116 this . #provider. setInterval ( callback , delay ) ,
0 commit comments