Skip to content

[vite-plugin] Clear v1 Worker exports between dev servers - #16503

Merged
petebacondarwin merged 1 commit into
codex/vite-v1-backport-16490from
codex/vite-v1-backport-16457
Oct 28, 2026
Merged

petebacondarwin merged 1 commit into
codex/vite-v1-backport-16490from
codex/vite-v1-backport-16457

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Backports #16457 to Vite plugin v1.

V1 also keeps detected Worker exports in module-level shared context after a dev server closes. Clear that map when disposing Miniflare so a later server derives exports from its own configuration. Otherwise a later Worker with a Durable Object can fail with Class extends value undefined.

Retain the original sequential-server integration regression, adapted to v1's wrangler.json with durable_objects and migrations. It starts and fetches from two real Vite servers in the same process; it does not restore the removed cf/cloudflare.config.ts configuration path or public dependency tests. The regression fails against the parent and passes with the fix.

Stacked on #16502 (retained Zod). This PR has only the independently remaining context cleanup, adapted plugin test, and original plugin patch changeset.

Validation: Node 22.22.1 / pnpm 10.33.0; pnpm build, pnpm check (including types), pnpm test:ci, and pnpm test:fixtures pass.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: fixes state cleanup between existing dev servers without changing configuration.

Note

This is a contribution from an AI agent: Codex.


Devin Review

@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 353bd12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@Eshan05 (recorded author of #16457) and @dario-piotrowicz (verified human ant-core approver), could you please check this Vite plugin v1 backport and approve it if it looks good?

V1 retains the same shared Worker export cache. The original cleanup is unchanged; the integration regression uses v1 wrangler.json, Durable Object bindings and migrations instead of the intentionally removed cf config. It reproduces Class extends value undefined against the parent and passes with the fix. Build, checks/types, all 217 plugin tests and retained fixtures pass. Earlier #16502 supplies the separate Zod upgrade without repeating it here.

@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team October 26, 2026 21:51
@workers-devprod

workers-devprod commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler

@clanky-the-clanker

Copy link
Copy Markdown

✅ Approved — This is a small, well-scoped backport. Clearing workerNameToExportTypesMap in disposeMiniflare stops a later dev server from reusing the previous server's Worker exports. Restarts keep the map because they skip disposal. The new regression test checks the case where two dev servers run one after the other in the same process. No issues found.

The decision is advisory: this comment never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Risk: Low. A patch changeset for the plugin is included, which fits this bug fix.


🔒 Security: ✅ LGTM

This only clears dev-time state. It has no security implications.


📖 AGENTS.md: ✅ LGTM

The change follows the repository guidelines: there is a plugin changeset, the title uses the [vite-plugin] prefix, and the tests use test-context expect.


📋 Code Quality: ✅ LGTM

disposeMiniflare now resets the shared workerNameToExportTypesMap. When the map is unset, the workerNameToExportTypesMap getter builds it from the current plugin config again, so the next server starts from its own config. Vite's restartServer path skips disposal (ctx.isRestartingDevServer), so export types detected for the current server are kept across restarts. The preview server's call to disposeMiniflare is not affected. The new sequential-dev-servers spec uses real temporary projects and Vitest's test-context expect, as the repository guidelines ask.


⚡ Performance: ✅ LGTM

No performance impact. The map is rebuilt from config only after Miniflare has been disposed.


📝 Documentation: ✅ LGTM

The new method has a JSDoc comment explaining the reset. No public documentation changes are needed.


Reviewed commit: 353bd124

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@cloudflare/vite-plugin@16503

commit: 353bd12

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@Eshan05

Eshan05 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

@Eshan05 (recorded author of #16457) and @dario-piotrowicz (verified human ant-core approver), could you please check this Vite plugin v1 backport and approve it if it looks good?

V1 retains the same shared Worker export cache. The original cleanup is unchanged; the integration regression uses v1 wrangler.json, Durable Object bindings and migrations instead of the intentionally removed cf config. It reproduces Class extends value undefined against the parent and passes with the fix. Build, checks/types, all 217 plugin tests and retained fixtures pass. Earlier #16502 supplies the separate Zod upgrade without repeating it here.

Looks right. It's the same change as the v2 fix, and v1 restarts don't call disposeMiniflare() either, so they still reuse the cached exports. Thanks for porting it.

@petebacondarwin
petebacondarwin removed this pull request from stack #16505 October 28, 2026 11:08
@petebacondarwin
petebacondarwin merged commit ca116f9 into vite-plugin-v1 Oct 28, 2026
42 of 43 checks passed
@petebacondarwin
petebacondarwin deleted the codex/vite-v1-backport-16457 branch October 28, 2026 11:34
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.

4 participants