Repository navigation
fix: flaky CI from early press timers and Yarn network crash - #1972
Merged
Merged
Conversation
Pressability measures press duration with Date.now() and defers onPressOut when it sees less than 130ms. Node timers can fire ~1ms early relative to Date.now(), so waiting setTimeout(130) occasionally left pressOut deferred and press() resolved before it fired. Wait out the remaining min press duration based on measured time instead of the requested duration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Yarn 4.11.0 bundles a got v11 client that can crash with "The `onCancel` handler was attached after the promise settled" when a registry request times out and its retry fires after the request already settled. Yarn 4.18.1+ guards that retry. This crashed nightly CI jobs while switching React Native versions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1972 +/- ##
=======================================
Coverage 98.60% 98.60%
=======================================
Files 88 88
Lines 1786 1789 +3
Branches 485 471 -14
=======================================
+ Hits 1761 1764 +3
Misses 24 24
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The root yarnPath applies to website, examples and experiments-app, which have their own lockfiles. CI restores cached node_modules and skips install, so Yarn 4.19.0 rejected the stale v8 website lockfile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes two causes of random CI failures. Each fix is its own commit.
1.
userEvent.presscould return beforepressOutwith real timersNightly runs failed in
press.real-timers.test.tsx("calls press when pressable has pointer events box-only") with the event sequencepressIn, pressand nopressOut.Pressability measures press duration with
Date.now(). If it sees less than 130ms (DEFAULT_MIN_PRESS_DURATION), it delaysonPressOutwith asetTimeout.emitPressabilityPressEventswaitedsetTimeout(130)and only waited for the delayedpressOutwhenduration < 130. Node timers can fire up to ~1ms early compared toDate.now()(libuv schedules from cached loop time). In about 1% of runs, RN measured 129ms, delayedpressOut, andpress()resolved before it fired.The fix records
Date.now()afterresponderGrantand beforeresponderRelease, then waits out whatever is left of the 130ms based on that measured time. With modern fake timersDate.now()is faked, so behavior there doesn't change.2. Yarn crashes on registry timeouts (upgrade 4.11.0 → 4.19.0)
Nightly jobs failed while switching RN versions with
Error: The onCancel handler was attached after the promise settled. In thegotv11 client bundled in Yarn, a retry scheduled after a timeout could fire after the request promise had already settled. The re-registered cancel handler then throws, which kills the process.Yarn 4.18.1+ guards the retry with a settled flag. I checked bundles 4.11.0 through 4.18.0: none has the guard, and 4.18.1 and 4.19.0 do. This PR upgrades to 4.19.0 (
yarn set version). The lockfile change is metadata only:__metadata.version8 → 10 and new hashes for Yarn's builtinresolvepatch.yarn set versionalso tried to addenableScripts: trueandapprovedGitRepositories: "**"to.yarnrc.ymlto keep the 4.11 defaults. I left them out:esbuildandunrs-resolverskip their build scripts. Both ship prebuilt binaries through optional dependencies.The example apps (
examples/basic,examples/cookbook) still pinyarn@4.11.0. They have their own lockfiles and are left for a follow-up.Test plan
yarn installwith Yarn 4.19.0, thenyarn validate: 90 suites and 963 tests pass, plus typecheck, lint and format.yarn buildpasses.press.real-timers.test.tsxpassed 25 times in a row locally. The flake is rare (about 1%) and wasn't reproduced locally before the fix, so this is a sanity check, not proof.setTimeout(130)sometimes measures under 130ms withDate.now()(2/200 locally).workflow_dispatchafter merge, or on this branch.🤖 Generated with Claude Code