Skip to content

Merge Vite server config with existing settings#1650

Open
alechoey wants to merge 1 commit intovanilla-extract-css:masterfrom
MutinyHQ:master
Open

Merge Vite server config with existing settings#1650
alechoey wants to merge 1 commit intovanilla-extract-css:masterfrom
MutinyHQ:master

Conversation

@alechoey
Copy link

Trying to launch a vite server with middlewareMode doesn't get propagated to the compiler vite server.

Without middlewareMode, the vite server directly handles SIGTERM and immediately exits the process. This breaks the parent server behavior (such as Fastify graceful shutdown)

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

⚠️ No Changeset found

Latest commit: f712ec0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@askoufis
Copy link
Contributor

askoufis commented Dec 7, 2025

@alechoey Thanks for the PR! Would it be possible for you to make a minimal reproduction of your issue? It would help me understand the problem better.

As it stands, I'm hesitant to blindly spread the entire server config into the compiler's vite server. This isn't because some options may cause problems (they may, I just haven't validated this), but primarily because future changes to vite's config options could cause incompatibilities. I'd rather be explicit about which configuration options are being forwarded to the compiler, i.e. only forward server.middlewareMode.

@alechoey
Copy link
Author

alechoey commented Jan 9, 2026

@askoufis Thanks for the feedback! I've created a minimal reproduction:

Repro: https://github.com/alechoey/vanilla-extract-middleware-repro

To run:

git clone https://github.com/alechoey/vanilla-extract-middleware-repro
cd vanilla-extract-middleware-repro
npm install
./test-sigterm.sh

The test clearly shows the issue with timestamps:

Control case (NO vanilla-extract) - graceful shutdown works:

[19:14:37.186] Received SIGTERM, starting graceful shutdown...
[19:14:37.186] Draining in-flight requests...
[19:14:37.188] Vite server closed
[19:14:46.196] Responding to /slow request     ← 9 seconds later, request completes!
[19:14:46.198] Graceful shutdown complete

With vanilla-extract - process exits immediately:

[19:14:55.470] Received SIGTERM, starting graceful shutdown...
[19:14:55.471] Draining in-flight requests...
                                              ← Process exits immediately, request never completes

At a minimum, we need to forward middlewareMode to the internal compiler's Vite server:

// In packages/compiler/src/compiler.ts
server: {
  hmr: false,
  watch: enableFileWatcher ? viteConfig.server?.watch : null,
  middlewareMode: viteConfig.server?.middlewareMode,  // Add this line
},

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.

2 participants