-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clearing instrumented intervals in 3p environmented frames cancels timers #40235
Comments
// Funciones de utilidad para gestionar integraciones de terceros en un iframe import { rethrowAsync } from '#core/error'; /** Almacena las integraciones de terceros registradas */ /** Lleva un registro de las cargas de scripts síncronas */ /**
/**
/**
/**
/**
/**
/**
const allFields = new Set([...requiredFields, ...optionalFields]); /**
/**
/**
|
@PsychodelEKS We just committed a fix to temporarily address your problem. #40238 It will be expected to go out to stable in 2 weeks. |
Thanks, I like the approach with 100500 id )) |
Developing an amp-ad integration I faced a problem with some of my timeouts not firing up correctly (at all actually), after some extensive investigation I found the native
clearInterval
call in the instrumented method to be the culprit. In was added in this commit.In native timers/intervals browser shares the same ids pool between those, so in any arbitrary point in time a pair of a timer and an interval with the same id value can not exist. Thus native
clearTimeout
andclearInterval
native methods do the same - cancel the delayed call by thetimerId
passed regardless of the timer/interval type, and either a timer or an interval can be cancelled with either of those (the difference of the methods is only in names).In the AMP lib the instrumented version of intervals uses own iterator to get/set ids for the created intervals and this numbering intersects with the browser built in used for timers. So the introduced call to the native
clearInterval
method for an interval id for which a native timer was previously created will cancel this timer as a unintended consequence.Here is a test code I used to demonstrate this (to test locally, I`ve created a fake adm-ad provider and added it to the ads.amp.html page)
The console output (the timer is actually never called as it is cancelled by the
clearInterval
call):I guess either the timers must share the "instrumented" ids and be cleared the same way as intervals, or the native
clearInterval
call must be removed from the instrumented method (direct cancelling of intervals from outside of the frame seems to be "strange" practice imo).The text was updated successfully, but these errors were encountered: