Skip to content

fix(plan): stop vitest reload flake from lazy zod optimization#15

Merged
blimmer merged 1 commit into
mainfrom
fix/plan-vitest-flake-12
May 6, 2026
Merged

fix(plan): stop vitest reload flake from lazy zod optimization#15
blimmer merged 1 commit into
mainfrom
fix/plan-vitest-flake-12

Conversation

@blimmer
Copy link
Copy Markdown
Contributor

@blimmer blimmer commented May 6, 2026

Summary

The plan package's vitest browser run was flaky because Vite's initial dep-scan didn't follow imports into workspace package source, so zod (transitively pulled in via @contextbridge/shared schema files) was discovered lazily mid-run and triggered a reload that raced with the next test file's import — crashing describe() with Cannot read properties of undefined (reading 'config'). Pointing optimizeDeps.entries at plan's src/**/*.{ts,tsx} forces the scanner to crawl through shared up front, so transitive deps land in the pre-bundle before any test loads.

Closes #12.

Review focus

  • Whether optimizeDeps.entries is the right layer for this. The alternative is declaring zod as a direct devDep on plan; I argued against that since plan never directly imports zod and bun's .bun/ isolation correctly enforces "import what you declare." The scan-based fix also stays durable if shared adds another transitive dep later — no per-dep maintenance.
  • Glob breadth: src/**/*.{ts,tsx} scans demo/storybook files too. Not harmful (those files only run under storybook, not vitest), but worth a sanity check that no story-only import accidentally pulls a heavy lib into the pre-bundle.

Commits

  • 0399e70 — fix(plan): pre-scan src for transitive deps to stop vitest reload flake

Vite's initial dep-scan was missing zod (transitively imported via
@contextbridge/shared schema files), so it got optimized lazily mid-run.
The optimize triggered a page reload that raced with whatever test file
vitest was importing next, leaving vitest's exports partially undefined
and crashing describe() with "Cannot read properties of undefined
(reading 'config')".

Pointing optimizeDeps.entries at plan's source forces the scanner to
follow imports through @contextbridge/shared up front, so all transitive
deps land in the pre-bundle before any test loads.

Closes #12
@blimmer blimmer marked this pull request as ready for review May 6, 2026 13:55
@blimmer blimmer requested a review from jcarver989 as a code owner May 6, 2026 13:55
@blimmer blimmer enabled auto-merge (squash) May 6, 2026 13:55
@blimmer blimmer merged commit 3b3cc0c into main May 6, 2026
13 checks passed
@blimmer blimmer deleted the fix/plan-vitest-flake-12 branch May 6, 2026 13:56
blimmer added a commit that referenced this pull request May 8, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.0](v0.2.0...v0.3.0)
(2026-05-08)


### ⚠ BREAKING CHANGES

* rename Claude plugin to planbridge@contextbridge; refresh plugins on
update ([#52](#52))

### Features

* add automatic release changelog with release-please
([#21](#21))
([45a1bf1](45a1bf1))
* rename Claude plugin to planbridge@contextbridge; refresh plugins on
update ([#52](#52))
([2794ae6](2794ae6))
* **ui:** add GitHub link to header help menu
([#19](#19))
([c36289b](c36289b))


### Bug Fixes

* emit plan review analytics from shared runner
([#48](#48))
([5c769ff](5c769ff))
* **plan:** pre-scan src for transitive deps to stop vitest reload flake
([3b3cc0c](3b3cc0c)),
closes [#12](#12)
* **plan:** stop vitest reload flake from lazy zod optimization
([#15](#15))
([3b3cc0c](3b3cc0c))
* refresh Claude marketplace cache during install
([#62](#62))
([58be09a](58be09a))
* resolve contextbridge via PATH for post-update refresh
([#64](#64))
([f658af4](f658af4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: contextbridge-pr-automation[bot] <259134118+contextbridge-pr-automation[bot]@users.noreply.github.com>
Co-authored-by: Ben Limmer <ben@benlimmer.com>
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.

bug: flakey test

1 participant