Skip to content

🌱 fix: nightly unit-test regression#21283

Merged
clubanderson merged 2 commits into
mainfrom
scanner/fix-21083
Jul 19, 2026
Merged

🌱 fix: nightly unit-test regression#21283
clubanderson merged 2 commits into
mainfrom
scanner/fix-21083

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Fixes #21083

Disables Vitest per-file isolate in CI to avoid "Worker exited unexpectedly" memory exhaustion introduced when the bundle was split into many small chunks (commit df9e0d1). Local development still runs with isolation enabled.

isolate: process.env.CI ? false : true,

Disable isolate mode in CI to prevent Vitest worker crashes when loading
hundreds of split chunks. The bundle split in #21269 created many small
chunks that cause memory exhaustion when isolate: true forces each test
file to reload all modules in a fresh process.

Trade-off: CI tests now share global state between test files (risking
vi.stubGlobal cross-contamination #20256), but local dev keeps isolation.

Signed-off-by: GitHub Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 19, 2026 09:19
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jul 19, 2026
@netlify

netlify Bot commented Jul 19, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit dbe165f
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a5cbf42d0aca0000846576b
😎 Deploy Preview https://deploy-preview-21283.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign eeshaansa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@kubestellar-prow kubestellar-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses nightly unit-test failures (#21083) by changing the Vitest configuration to disable per-file isolation in CI, aiming to reduce memory pressure and avoid “Worker exited unexpectedly” crashes introduced after the bundle was split into many smaller chunks.

Changes:

  • Disable vitest.test.isolate when process.env.CI is set, while keeping isolation enabled for local runs.
  • Document the CI-specific rationale (memory exhaustion / worker crashes) alongside the config change.

Comment thread web/vite.config.ts
Comment on lines 402 to +405
// isolate: true ensures each test file runs in its own subprocess with a clean global environment,
// preventing vi.stubGlobal() cross-contamination between files (#20256)
isolate: true,
// preventing vi.stubGlobal() cross-contamination between files (#20256). Disabled in CI to prevent
// worker crashes from excessive memory usage when loading hundreds of split chunks per test file (#21083)
isolate: process.env.CI ? false : true,

@clubanderson clubanderson left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[quality] Review — this is a workaround that reintroduces a bug the current comment explicitly documents (comment mode; self-approve blocked)

The 1-line diff is small, but read the two lines together:

// isolate: true ensures each test file runs in its own subprocess with a clean global environment,
// preventing vi.stubGlobal() cross-contamination between files (#20256). Disabled in CI to prevent
// worker crashes from excessive memory usage when loading hundreds of split chunks per test file (#21083)
isolate: process.env.CI ? false : true,

The comment now literally says "in CI, we accept the vi.stubGlobal() cross-contamination bug from #20256 to work around #21083." That's a strict regression on the exact axis that CI is supposed to catch — a locally-passing test suite that flakes only in CI is worse than one that runs slowly in CI.

Concrete concerns:

1. #20256 is a real class of bug, not theoretical

The comment was added deliberately (probably after debugging pain) to prevent vi.stubGlobal() bleed between test files. In CI, tests now share a process, so any file that does vi.stubGlobal('fetch', ...) and forgets to vi.unstubAllGlobals() in afterEach will silently mutate state seen by later files. Test order will start mattering. This is exactly the class of flake that's hard to reproduce locally (where isolate: true still holds) and hard to diagnose in CI.

Quick grep before merging: rg -l 'stubGlobal|stubEnv' web/src — every file that uses these must have symmetric unstub* in afterEach. If any don't, they're time bombs under this config.

2. The real fix is upstream, not here

"Loading hundreds of split chunks per test file" during a unit test is itself a symptom — unit tests shouldn't be pulling in the whole bundle. Two likelier root causes:

  • coverage.all: true somewhere forcing v8 to import every source file (the surrounding lines mention coverage.all — check its value).
  • Eager top-level imports in a widely-imported module (e.g., a barrel index.ts that transitively pulls in all cards/drilldowns).
  • Bundle-split rules in vite.config.ts (from #21269) whose manualChunks function is being evaluated in the test transform path.

A vitest run with --reporter=verbose and NODE_OPTIONS='--max-old-space-size=8192 --heap-prof' would tell you which chunk is memory-heavy. That's a targeted fix; this PR is a shotgun.

3. If you must ship a workaround, better knobs exist

Try any of these instead, in order of preference:

  • pool: 'forks' + poolOptions.forks.singleFork: false, isolate: true: keeps isolation but uses cheaper fork boundaries instead of worker threads.
  • Reduce maxThreads/maxWorkers to 2 in CI: caps concurrent memory instead of removing isolation entirely. The existing config already has a threads: { maxThreads: 1, minThreads: 1 } branch — is that branch actually being taken in CI?
  • env.CI fileParallelism false: fileParallelism: process.env.CI ? false : true — runs files sequentially with isolation kept. Slower but not a correctness regression.

4. Also

  • The 1-line ternary is fine syntactically but isolate: process.env.CI !== undefined ? false : true would be more resilient to CI="" (empty string is falsy → isolate stays true, which is probably not the intent).
  • Because CI now sees a different config than local, the workflow file should probably run vitest with --run --reporter=default,junit and also validate the config diff isn't drifting further.

Bead filed. Not merging.


Filed by quality agent (ACMM L4/L6 — full mode)

@clubanderson
clubanderson merged commit 294a689 into main Jul 19, 2026
19 of 22 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-21083 branch July 19, 2026 12:13
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 294a6895c00aa7213d48879b39a5fc3ac633967b
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/29686577754

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 294a6895c00aa7213d48879b39a5fc3ac633967b.

clubanderson added a commit that referenced this pull request Jul 19, 2026
…age (partial fix for #21284) (#21290)

PR #21283 set isolate:false in CI to avoid worker OOM (#21083), but that
disables Vitest's per-file subprocess isolation. With 143 test files
calling vi.stubGlobal (many at module scope), those stubs leak into
subsequent files. vi.unstubAllGlobals() in setup.ts's afterAll runs only
once per worker (end of shard) under isolate:false, not once per file,
so cross-file contamination produced 1598 failures in Coverage Suite
run #4339.

Restore isolate:true unconditionally. The original OOM issue #21083 must
be addressed via chunk-splitting tuning or a memory bump rather than by
disabling test isolation.

Refs #21284

Signed-off-by: GitHub Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: GitHub Copilot <223556219+Copilot@users.noreply.github.com>
clubanderson added a commit that referenced this pull request Jul 19, 2026
…#21296)

Update the afterAll comment in setup.ts to accurately describe the current
isolate:true behaviour (afterAll runs once per FILE, correctly cleaning up
vi.stubGlobal() stubs) and to warn that setting isolate:false causes
afterAll to run only once per shard — the root cause of 1598 test failures
in Coverage Suite run #4339.

Root-cause summary for #21284:
  PR #21283 set isolate:process.env.CI?false:true to work around suspected
  OOM crashes from chunk-splitting (#21083).  With isolate:false all test
  files in a shard share one Vitest worker process.  vi.stubGlobal() calls
  made at module scope in one file leaked into every subsequent file; the
  afterAll vi.unstubAllGlobals() in setup.ts ran only once at the end of
  the shard, not once per file, so contamination accumulated.
  Restoring isolate:true (PR #21290, commit 0f81cb0) fixed the failures.
  This commit updates setup.ts to make that constraint explicit and to
  point future maintainers at the full explanation in vite.config.ts.

Fixes #21284

Signed-off-by: Scanner <scanner@kubestellar.io>
Co-authored-by: Scanner <scanner@kubestellar.io>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly regression: unit-test

3 participants