Skip to content

[Refactor] Improve CI Run Times by Reducing Test Flakiness and Speeding up Test Suite#1166

Merged
N2D4 merged 11 commits into
devfrom
reduce-test-flakeyness
Feb 11, 2026
Merged

[Refactor] Improve CI Run Times by Reducing Test Flakiness and Speeding up Test Suite#1166
N2D4 merged 11 commits into
devfrom
reduce-test-flakeyness

Conversation

@N2D4
Copy link
Copy Markdown
Contributor

@N2D4 N2D4 commented Feb 6, 2026

Context

Our CI has evinced a few flakey tests recently. Additionally, the freestyle-prod action takes a long time to run. These end up delaying the merging/iterative development processes. There was also a bug with the existing implementation of getExternalDbSyncFusebox where it was performing an upsert, which according to prisma, could cause conflicts. getExternalDbSyncFusebox was trying to upsert the settings singleton for the fusebox lazily if it wasn't updated yet, and if multiple upserts are occurring at once it can cause a rare unique key constraint violation on the singleton settings key. The fix is to not have the get function attempt an update.


Note

Medium Risk
Touches internal external-db-sync control flow and test/CI orchestration; behavior changes could affect how quickly sync-driven tests converge, though changes are scoped to internal endpoints and test harnesses.

Overview
Reduces E2E/CI flakiness by removing the test-only “force external DB sync” mechanism and the stopWhenIdle query behavior from the internal external-db-sync sequencer/poller, so sync runs consistently for the full maxDurationMs (with added lightweight logging when work is found).

Stabilizes email-related tests by centralizing outbox helpers in backend-helpers, switching tests from fixed sleeps to polling for outbox status, and improving failure diagnostics by including outbox state in assertion errors. CI workflows are updated accordingly (drop STACK_FORCE_EXTERNAL_DB_SYNC, and adjust prod PR runs to execute the mail test subset).

Written by Cursor Bugbot for commit 7bed7c5. This will update automatically on new commits. Configure here.

Additional Notes

Note that we also update the Action for freestyle-prod to only run the mail tests on non-dev and non-main branches. This is because freestyle is used for email-rendering, and so, those tests are the ones we're chiefly concerned about. Running freestyle-prod tests for non-mail tests broadly doesn't reveal any information that we wouldn't get from the freestyle-mock tests and the mail tests. However, to account for the edge cases where it would, we let it run to completion on dev and main.

Summary by CodeRabbit

  • Chores
    • Removed forced external DB sync flag from CI workflows; adjusted test invocation to append a "mail" argument in certain prod freestyle runs.
  • Refactor
    • Removed idle-stop behavior from synchronization services for steadier, duration-driven operation.
  • Tests
    • Consolidated outbox/email helpers and standardized status-based waits; replaced fixed sleeps with polling.
    • Removed manual force-sync triggers, introduced marker/condition verification and increased several test timeouts.
    • Swapped one OTP sign-in precondition for a fast signup in a user test.

Copilot AI review requested due to automatic review settings February 6, 2026 22:52
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-backend Ready Ready Preview, Comment Feb 11, 2026 1:48am
stack-dashboard Ready Ready Preview, Comment Feb 11, 2026 1:48am
stack-demo Ready Ready Preview, Comment Feb 11, 2026 1:48am
stack-docs Ready Ready Preview, Comment Feb 11, 2026 1:48am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Removed STACK_FORCE_EXTERNAL_DB_SYNC from multiple GitHub Actions; removed stopWhenIdle idle-stop behavior from external-db-sync poller and sequencer routes; consolidated outbox email helpers into shared e2e backend-helpers and updated tests to use status-based waiting; removed force-sync utilities from external-db-sync test helpers.

Changes

Cohort / File(s) Summary
GitHub Actions — remove env flag
.github/workflows/e2e-api-tests.yaml, .github/workflows/e2e-custom-base-port-api-tests.yaml, .github/workflows/e2e-source-of-truth-api-tests.yaml, .github/workflows/restart-dev-and-test-with-custom-base-port.yaml, .github/workflows/restart-dev-and-test.yaml, .github/workflows/setup-tests-with-custom-base-port.yaml, .github/workflows/setup-tests.yaml
Removed STACK_FORCE_EXTERNAL_DB_SYNC: "true" from job environments; also appended a "mail" arg to a test invocation in one prod freestyle non-main/dev case.
Backend — external-db-sync poller & sequencer
apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts, apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts
Removed stopWhenIdle query parsing, span attribute, and idle-based early-stop paths; updated iteration result types to remove "idle"; left backfill/enqueue behavior intact.
E2E shared helpers — backend
apps/e2e/tests/backend/backend-helpers.ts
Added shared outbox utilities: getOutboxEmails(...) and waitForOutboxEmailWithStatus(...); include outbox emails in sign-in failure payloads.
E2E email helpers & tests
apps/e2e/tests/backend/endpoints/api/v1/emails/email-helpers.ts, apps/e2e/tests/backend/endpoints/api/v1/emails/email-queue.test.ts, apps/e2e/tests/backend/endpoints/api/v1/emails/outbox-api.test.ts
Removed local outbox types/helpers and re-exported/shared new helpers; replaced fixed sleeps/polls with waitForOutboxEmailWithStatus and adjusted related imports and assertions.
E2E external-db-sync utils & tests
apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-utils.ts, apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts
Removed force-sync flags, timers, and exported forceExternalDbSync; replaced forced-sync + sleeps with marker-based polling via waitForCondition and metadata checks.
E2E auth tests
apps/e2e/tests/backend/endpoints/api/v1/users.test.ts
Replaced one test precondition from Auth.Otp.signIn() to Auth.fastSignUp() in the "without project access" case.

Sequence Diagram(s)

sequenceDiagram
    participant CI as CI / Workflow
    participant Test as E2E Tests
    participant API as Backend API (poller/sequencer)
    participant DB as External DB

    CI->>Test: start e2e job (no STACK_FORCE_EXTERNAL_DB_SYNC)
    Test->>API: GET /internal/external-db-sync/(poller|sequencer) (start iteration)
    API->>DB: query pending requests / sequences
    alt pending requests exist
        API->>API: process/enqueue pending work
        API-->>Test: iteration result (processed>0, stopReason=null)
    else no pending requests
        API->>API: continue until max-duration (no idle stop)
        API-->>Test: iteration result (processed=0, stopReason=null)
    end
    Test->>DB: poll for marker/metadata (waitForCondition)
    DB-->>Test: marker appears -> Test asserts external state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • BilalG1

Poem

🐰 I hopped through envs and idle springs,

took out a flag and quieted rings,
helpers gathered in one neat den,
tests now wait for statuses, not when,
the warren nods — the code leaps again.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[Refactor] Improve CI Run Times by Reducing Test Flakiness and Speeding up Test Suite' accurately captures the main objectives of the changeset: removing flakiness-inducing mechanisms (force external DB sync, stopWhenIdle), stabilizing email tests with polling, and optimizing CI workflows.
Description check ✅ Passed The PR description provides clear context, objectives, and reasoning for the changes including background on test flakiness, the force-sync mechanism removal, email test stabilization, and CI workflow updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch reduce-test-flakeyness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

  • Removes STACK_FORCE_EXTERNAL_DB_SYNC from CI workflows and adjusts prod PR runs to execute only the mail-focused test subset.
  • Refactors e2e email tests to poll the outbox API for specific statuses instead of fixed sleep(7000) delays.
  • Simplifies external DB sync testing by removing forced-sync endpoints usage and switching to polling-based convergence checks.
  • Backend external-db-sync sequencer/poller endpoints were changed to drop stopWhenIdle-based early exit behavior and add some diagnostic logging.

Confidence Score: 3/5

  • This PR is likely safe to merge after addressing a few contract/flake regressions in external-db-sync endpoints and e2e helpers.
  • Most changes are CI/test-flake reductions, but there are a few concrete issues: poller still advertises stopWhenIdle without implementing it, sequencer’s types still imply an idle stopReason, and the new outbox polling helper assumes ordering that can cause timeouts when subjects collide. Fixing these should make behavior consistent and keep flakiness improvements intact.
  • apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts; apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts; apps/e2e/tests/backend/backend-helpers.ts; apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-utils.ts

Important Files Changed

Filename Overview
.github/workflows/e2e-api-tests.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC env and conditionally runs only 'mail' tests for prod PRs; no functional issues found in workflow syntax.
apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts Removes stopWhenIdle parsing/behavior but leaves stopWhenIdle in request schema; poller now always runs until maxDurationMs and adds console log.
apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts Removes stopWhenIdle query param/early-exit but retains types that imply 'idle' stopReason; adds console log on didUpdate.
apps/e2e/tests/backend/backend-helpers.ts Moves outbox polling helpers into shared backend-helpers and enriches OTP failure diagnostics; wait helper assumes first matching email ordering.
apps/e2e/tests/backend/endpoints/api/v1/emails/outbox-api.test.ts Replaces fixed waits with waitForOutboxEmailWithStatus to reduce flakiness; depends on helper correctness.
apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-utils.ts Removes forceExternalDbSync plumbing and adds DB manager cleanup; TestDbManager maps clients by non-unique key vs unique DB name.

Sequence Diagram

sequenceDiagram
  participant Cron as Vercel Cron
  participant Seq as Sequencer endpoint
  participant DB as Primary DB
  participant Queue as Sync queue
  participant Poll as Poller endpoint
  participant QStash as Upstash QStash

  Cron->>Seq: "GET /sequencer?maxDurationMs"
  loop "until maxDurationMs"
    Seq->>DB: "backfill sequence ids"
    DB-->>Seq: "didUpdate + tenantIds"
    opt "didUpdate"
      Seq->>Queue: "enqueueExternalDbSyncBatch(tenantIds)"
    end
  end
  Seq-->>Cron: "200 OK"

  Cron->>Poll: "GET /poller?maxDurationMs"
  loop "until maxDurationMs"
    Poll->>DB: "claimPendingRequests()"
    DB-->>Poll: "OutgoingRequest[]"
    opt "requests.length>0"
      Poll->>QStash: "batchJSON/publishJSON"
      Poll->>DB: "deleteOutgoingRequests(ids)"
    end
  end
  Poll-->>Cron: "200 OK"
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment thread apps/e2e/tests/backend/backend-helpers.ts Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 6, 2026

Additional Comments (2)

apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts
Stale query schema field

stopWhenIdle is still accepted by the Yup query schema (query: { stopWhenIdle: ... }), but the handler no longer reads it and always keeps polling until maxDurationMs. This makes the API surface misleading and breaks callers that relied on stopWhenIdle=true to return quickly (previously used by e2e forceExternalDbSync). Either re-implement the early-exit behavior or remove stopWhenIdle from the schema entirely so requests don’t imply support for it.


apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-utils.ts
DB client keyed incorrectly

TestDbManager.createDatabase stores the client in this.databases under the non-unique dbName (this.databases.set(dbName, client)), but the actual DB created is uniqueDbName. If the same logical dbName is reused across tests (or retries), the previous client will be overwritten while the old uniqueDbName remains in databaseNames and may never be connected/closed properly. This can lead to leaked connections and failed cleanup. Keying databases by uniqueDbName (or storing a mapping of logical->unique and keeping both) avoids that mismatch.

Copy link
Copy Markdown

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The stopWhenIdle query parameter is defined in the request schema but never parsed or used in the handler, creating an API compatibility inconsistency

Fix on Vercel

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce E2E test flakiness by removing email/cron timing assumptions and consolidating polling helpers used across the backend API test suite.

Changes:

  • Replace OTP-based sign-in and fixed sleeps with faster signup + polling helpers for email outbox status.
  • Remove “force external DB sync” test utilities and adjust external DB sync tests to rely on cron-driven syncing.
  • Update internal external-db-sync cron endpoints and CI workflows (env + test invocation behavior).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
apps/e2e/tests/backend/endpoints/api/v1/users.test.ts Switches to Auth.fastSignUp() to avoid OTP email timing.
apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-utils.ts Removes forced-sync feature and related env/config logic.
apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts Replaces forced sync / long sleep with a short waitForCondition-based check.
apps/e2e/tests/backend/endpoints/api/v1/emails/outbox-api.test.ts Uses centralized waitForOutboxEmailWithStatus polling instead of fixed sleeps.
apps/e2e/tests/backend/endpoints/api/v1/emails/email-queue.test.ts Removes duplicated outbox polling helpers in favor of backend-helpers exports.
apps/e2e/tests/backend/endpoints/api/v1/emails/email-helpers.ts Re-exports outbox helpers from backend-helpers.
apps/e2e/tests/backend/backend-helpers.ts Adds shared outbox helpers + includes outbox dump in OTP failure diagnostics.
apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts Removes stopWhenIdle and adds backfill progress logging.
apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts Removes stopWhenIdle behavior and adds “pending requests” logging.
.github/workflows/setup-tests.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC.
.github/workflows/setup-tests-with-custom-base-port.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC.
.github/workflows/restart-dev-and-test.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC.
.github/workflows/restart-dev-and-test-with-custom-base-port.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC.
.github/workflows/e2e-source-of-truth-api-tests.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC.
.github/workflows/e2e-custom-base-port-api-tests.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC.
.github/workflows/e2e-api-tests.yaml Removes STACK_FORCE_EXTERNAL_DB_SYNC and changes prod-mode PR test command to append a mail filter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/e2e-api-tests.yaml
Comment thread apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts Outdated
Comment thread apps/e2e/tests/backend/backend-helpers.ts
Comment thread apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts Outdated
Comment thread apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@apps/e2e/tests/backend/backend-helpers.ts`:
- Around line 203-210: In waitForOutboxEmailWithStatus, don't assume the first
returned email matches the desired status; instead inspect all emails returned
by getOutboxEmails({ subject }) (e.g., use Array.prototype.find or filter) and
return when any email's status === status (or return the list of matching
emails) so the function succeeds if any email with the subject has the requested
status rather than only checking emails[0]; update the return value and loop
condition accordingly.
- Around line 189-210: The helpers getOutboxEmails and
waitForOutboxEmailWithStatus use untyped "any" (and an eslint-disable) which
violates the guideline—replace the implicit any with a concrete type (e.g.,
define/use OutboxEmail or reuse EmailOutboxCrud/EmailOutboxItem from
stack-shared) and update function signatures/variables to use that type; remove
the eslint-disable and, if you truly cannot avoid any, add a one-line comment
explaining why and where (but prefer creating/importing the OutboxEmail type and
using it for listResponse.body.items and the emails variable in
waitForOutboxEmailWithStatus).

In `@apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts`:
- Around line 376-393: The current waitForCondition is vacuous because the
baseline already has one row, so change the wait predicate to detect a new sync
completion (e.g., wait for a changing sentinel field, a sync timestamp/sequence
column, or force a sync cycle and wait for that side-effect) rather than just
res.rows.length === 1; update the block using externalClient.query(...) inside
waitForCondition to check that sentinel/timestamp/version has advanced compared
to a captured pre-sync value (or trigger a sync and wait for its known marker),
and replace the loose row: any declaration with a proper type matching the query
result ({ display_name: string | null }) or a small explanatory comment if any
is unavoidable; refer to waitForCondition, externalClient.query, row, and dbName
to locate and implement these changes.
🧹 Nitpick comments (2)
apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts (1)

231-234: Stale "idle" variant in PollerIterationResult.

With the removal of idle-based termination, no code path returns { stopReason: "idle" } anymore. Consider removing "idle" from the stopReason union to keep the type accurate.

 type PollerIterationResult = {
-  stopReason: "disabled" | "idle" | null,
+  stopReason: "disabled" | null,
   processed: number,
 };
apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts (1)

197-199: Stale "idle" variant in SequencerIterationResult.

Same as the poller: no code path returns "idle" anymore. Clean up for consistency.

 type SequencerIterationResult = {
-  stopReason: "disabled" | "idle" | null,
+  stopReason: "disabled" | null,
 };

Comment thread apps/e2e/tests/backend/backend-helpers.ts
Comment thread apps/e2e/tests/backend/backend-helpers.ts Outdated
Comment thread apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts Outdated
@N2D4 N2D4 assigned nams1570 and unassigned N2D4 and nams1570 Feb 7, 2026
Comment thread apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts Outdated
Comment thread apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts Outdated
Comment thread apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts Outdated
Comment thread apps/e2e/tests/backend/backend-helpers.ts
Comment thread apps/e2e/tests/backend/backend-helpers.ts
N2D4 and others added 3 commits February 9, 2026 18:27
Before the waitFor condition would just terminate early.
Now, we use a marker txn and verify that a sync has run by polling until the committed marker txn appears in the external db.
We do a secondary check to see if seq number has grown to ensure that a sync has happened.
Note external dbs are unique for each test, so no chance of conflict or overlap.
The cron scheduler is running the seq + poller in the background.
@nams1570 nams1570 force-pushed the reduce-test-flakeyness branch from 7bed7c5 to 1a2f3a9 Compare February 10, 2026 21:10
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts (1)

228-257: ⚠️ Potential issue | 🟠 Major

stopReason is computed but never acted upon — disabled poller spins for the full duration.

iterationResult.stopReason is set to "disabled" when the fusebox disables the poller (line 242), but the while loop never checks it. This means a disabled poller will keep looping every 50ms for the entire maxDurationMs (default 3 minutes), wasting resources on no-op iterations.

If removing the "idle" break was intentional, the "disabled" case likely still warrants an early exit.

Proposed fix
         iterationCount++;
         totalRequestsProcessed += iterationResult.processed;
 
+        if (iterationResult.stopReason != null) {
+          break;
+        }
+
         await wait(pollIntervalMs);
       }
apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts (1)

194-227: ⚠️ Potential issue | 🟠 Major

Same issue: stopReason "disabled" is never checked — disabled sequencer spins for the full duration.

Identical to the poller route: when fusebox.sequencerEnabled is false (line 207), the iteration returns { stopReason: "disabled" }, but the while loop never breaks on it. Consider adding a break condition here as well.

Proposed fix
         iterations++;
+
+        if (iterationResult.stopReason != null) {
+          break;
+        }
+
         await wait(pollIntervalMs);
       }

@nams1570 nams1570 force-pushed the reduce-test-flakeyness branch from 0ab2ba0 to 93fda47 Compare February 10, 2026 21:32
@nams1570 nams1570 changed the title Reduce test flakeyness [Refactor] Improve CI Run Times by Reducing Test Flakiness and Speeding up Test Suite Feb 10, 2026
@nams1570 nams1570 force-pushed the reduce-test-flakeyness branch from 7142997 to aa101fc Compare February 10, 2026 22:20
Cron waits for up to 120 seconds between runs.
The test has a 120 second timeout.
So if cron is at the end of its random wait when the tests start, there can be a timeout.
This is an edge case that causes flakiness.
We bump the timeout to 150s to provide a buffer.
These tests need to wait for a sync to happen, so they need to wait for the cron job to run.
Specifically the cleanup and init hooks.
The default timeout is 10s.
We create so many dbs in the tests that timeout can take a while.
This makes the tests less flakey.
@nams1570 nams1570 force-pushed the reduce-test-flakeyness branch from 4501fba to a8c94c7 Compare February 10, 2026 23:50
getExternalDbFusebox used to lazy init the settings singleton.
However, this caused issues.
Prisma's upsert isn't safe from race conditions.
So this could cause collisions/ unique key issues.
Get doesn't need to update anything. Let's just return default values and have the update handle the init.
Tested on local that fusebox updates work fine.
@nams1570 nams1570 force-pushed the reduce-test-flakeyness branch from a8c94c7 to 7f97015 Compare February 11, 2026 00:02
This is unrelated to the previous changes. This test was flaky before.
waiting can often lead to timeout issues/ race conditions.
Polling with early exit is a better pattern.
We refactor to bring things in line with the other tests
@N2D4 N2D4 merged commit adb14f1 into dev Feb 11, 2026
27 checks passed
@N2D4 N2D4 deleted the reduce-test-flakeyness branch February 11, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants