Skip to content

fix(requestIdleCallback): timeout not assigned at NativeIdleCallbacks#57571

Open
pakerwreah wants to merge 1 commit into
react:mainfrom
pakerwreah:fix/request-idle-callback-timeout
Open

fix(requestIdleCallback): timeout not assigned at NativeIdleCallbacks#57571
pakerwreah wants to merge 1 commit into
react:mainfrom
pakerwreah:fix/request-idle-callback-timeout

Conversation

@pakerwreah

@pakerwreah pakerwreah commented Jul 15, 2026

Copy link
Copy Markdown

Summary:

Fix #57570

Regression in requestIdleCallback introduced by:

The timeout is never assigned, so it is never forwarded to runtimeScheduler.

Before the PR mentioned above, it was being assigned alongside expirationTime, but that was removed during the refactor.

Without this patch the task will keep running for up to 5 minutes (default value).

Changelog:

[GENERAL] [FIXED] - Fix requestIdleCallback timeout option being ignored

Test Plan:

Before After
before after

@meta-cla

meta-cla Bot commented Jul 15, 2026

Copy link
Copy Markdown

Hi @pakerwreah!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Jul 15, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 15, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 15, 2026
@TheAdamBorek

TheAdamBorek commented Jul 16, 2026

Copy link
Copy Markdown

Hey @pakerwreah. In your playground, are you sure requestIdleCallback respects "exactly" the timeout you have passed in?

I've been also investigation an issue around requestIdleCallback and I've noticed there's also this

? timeoutForSchedulerPriority(SchedulerPriority::LowPriority) +
customTimeout

timeout value for Low priority is:

case SchedulerPriority::LowPriority:
return HighResDuration::fromChrono(std::chrono::seconds(10));

With that being said, won't that trigger timeout 10s later than we actually want?

@pakerwreah

Copy link
Copy Markdown
Author

@TheAdamBorek yeah, even with the patch, it is not respecting exactly my custom timeout. It is just winning the race against the low priority starving tasks.

I'm not sure if that was already the case before the refactoring that caused the regression.

@pakerwreah

Copy link
Copy Markdown
Author

If I just return customTimeout from getResolvedTimeoutForIdleTask we get the expected result. (1ms - 10ms)

Screenshot_1784193248 Screenshot_1784193201

@pakerwreah

Copy link
Copy Markdown
Author

The whole reason I found this bug is because I'm trying to migrate from InteractionManager.runAfterInteractions which is deprecated.

We get a warning saying:

InteractionManager has been deprecated and will be removed in a future release.
Please refactor long tasks into smaller ones, and  use 'requestIdleCallback' instead.

But if we can't get a timeout under 10s, this is not a proper replacement. 🫤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in requestIdleCallback makes timeout option a no-op

2 participants