From 5d0c3c161449a751048e019b55dddfdfffd8e5ab Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Thu, 17 Sep 2026 19:32:45 +0200 Subject: [PATCH] fix: run Nitro in-process in Start WebContainers --- src/utils/example-webcontainer-start.ts | 3 +++ tests/example-webcontainer-start.test.ts | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/utils/example-webcontainer-start.ts b/src/utils/example-webcontainer-start.ts index 503b10efe..f2edf5987 100644 --- a/src/utils/example-webcontainer-start.ts +++ b/src/utils/example-webcontainer-start.ts @@ -104,6 +104,8 @@ export function getWebContainerStartEnv(runtime: ExampleRuntime) { if (runtime.compatibility === tanStackStartAsyncContextCompatibility) { env.NAPI_RS_NATIVE_LIBRARY_PATH = '@rolldown/binding-wasm32-wasi' + // Nitro's default node-worker never finishes loading in WebContainer. + env.NITRO_DEV_RUNNER = 'self' } return env @@ -152,6 +154,7 @@ export default defineConfig(async (configEnv) => { plugins: [tanStackStartAsyncContextPlugin()], resolve: { noExternal }, ssr: { noExternal }, + nitro: { devServer: { runner: 'self' } }, }) }) ` diff --git a/tests/example-webcontainer-start.test.ts b/tests/example-webcontainer-start.test.ts index e88cdf889..0a683da7f 100644 --- a/tests/example-webcontainer-start.test.ts +++ b/tests/example-webcontainer-start.test.ts @@ -49,6 +49,7 @@ describe('TanStack Start WebContainer compatibility', () => { assert.deepEqual(getWebContainerStartEnv(startRuntime), { __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS: '.webcontainer-api.io', NAPI_RS_NATIVE_LIBRARY_PATH: '@rolldown/binding-wasm32-wasi', + NITRO_DEV_RUNNER: 'self', }) assert.deepEqual( getWebContainerStartEnv({ @@ -85,6 +86,10 @@ describe('TanStack Start WebContainer compatibility', () => { files[tanStackStartViteConfigPath] ?? '', /"@tanstack\/start\*\*"/, ) + assert.match( + files[tanStackStartViteConfigPath] ?? '', + /nitro: \{ devServer: \{ runner: 'self' \} \}/, + ) assert.equal( files['/.tanstack/async-context-plugin.mjs'], tanStackStartAsyncContextPluginSource,