-
Notifications
You must be signed in to change notification settings - Fork 13
Add support for tracking work scheduled via setTimeout #24
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
base: main
Are you sure you want to change the base?
Conversation
Wait for asynchronous work scheduled through `setTimeout` with delays under 5000ms. Wrapped `window.setTimeout` and`window.clearTimeout` to track and signal ongoing work.
|
Thanks for looking into the synchronization of timeouts @stephanmoneybird . I'm afraid merging it like this would freeze synchronization in many apps I have seen, which use a pattern like this: async function startPinging() {
await fetch('/ping') // or do any other async work
setTimeout(startPinging, 1000)
}
startPinging()This is the correct implementation of polling, as What we could do is to lower the threshold so something like 10ms. This would synchronize all the cases where people use It would probably be nice to have a configuration for the threshold, maybe like this: Capybara::Lockstep.wait_timeout_max_delay = 10 # default
Capybara::Lockstep.wait_timeout_max_delay = 2000 # custom setting
Capybara::Lockstep.wait_timeout_max_delay = -1 # disable setTimeout() syncWe already have precedent for a config setting in I only have two comments about the diff itself:
Thanks for writing a test! |
|
I've processed your feedback, let me know what you think! |
Ad support for tracking asynchronous work scheduled via
setTimeout. AnysetTimeoutcall with a delay less than 5000ms is wrapped so that capybara-lockstep knows to wait for that work to complete before proceeding.