fix: use microtask queue for whatwg-fetch XHR events#94399
Open
rohit9625 wants to merge 2 commits into
Open
Conversation
Replaces `setTimeout(0)` with `queueMicrotask` for XHR event handlers within the `whatwg-fetch` polyfill.
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
In React Native (iOS), we observed cases where:
xhr.onloadexecuted successfully.Because the promise resolution depends on a timer, any environment-specific issue affecting timer delivery can prevent completed requests from resolving promptly.
So this PR replaces
setTimeout(0)withqueueMicrotaskfor XHR event handlers within thewhatwg-fetchpolyfill.Why
queueMicrotask? : Microtasks are generally executed as part of the current JavaScript turn after the current call stack unwinds and do not depend on timer infrastructure. Also, I don't see any benefit of usingsetTimeouthere because we are passing0as a timeout that is supposed to be executed as soon as possible. So, we should better usequeueMicrotaskhere.Fixed Issues
$ #90309
PROPOSAL: $ #90309 (comment)
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-06-24.at.9.15.44.AM.mov
Android: mWeb Chrome
Screen.Recording.2026-06-24.at.8.30.50.AM.mov
iOS: Native
Screen.Recording.2026-06-24.at.8.49.51.AM.mov
iOS: mWeb Safari
Screen.Recording.2026-06-24.at.8.41.16.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-06-24.at.8.21.36.AM.mov