Skip to content

🐛 BUG: Running vitest from the C3 default SvelteKit project results in "something prevents Vite server from exiting" #7717

@bigmac44

Description

@bigmac44

Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare)

What versions are you using?

3.99.0

What operating system and version are you using?

Mac Sequoia 15.2

Please provide a link to a minimal reproduction

No response

Describe the Bug

TLDR
Vitest tests should work without timeouts / warnings when following Cloudflare's sveltekit quickstart.


Following the instructions here:
https://developers.cloudflare.com/workers/frameworks/framework-guides/svelte/

To create a minimal svelte kit app with only the vitest extra added.

When running vitest via npm run test, it exits with the warning:

close timed out after 10000ms
Tests closed successfully but something prevents Vite server from exiting

Additionally, I've tried adding the workers vitest integration and still receive the same warning.

Please provide any relevant error logs

Console logs of a minimal c3 install w/ sveltekit and vitest, showing the "something prevents Vite server from exiting" warning at the end.

erikt@m1miniether cftest % npm create cloudflare@latest my-svelte-app -- --framework=svelte --experimental
Need to install the following packages:
create-cloudflare@2.36.0
Ok to proceed? (y) y


> npx
> create-cloudflare my-svelte-app --framework=svelte --experimental


────────────────────────────────────────────────────────────────────────────────
👋 Welcome to create-cloudflare v2.36.0!
🧡 Let's get started.

🧪 Running in experimental mode

📊 Cloudflare collects telemetry about your usage of Create-Cloudflare.

Learn more at: https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/telemetry.md
────────────────────────────────────────────────────────────────────────────────

╭ Create an application with Cloudflare Step 1 of 3
│
├ In which directory do you want to create your application?
│ dir ./my-svelte-app
│
├ What would you like to start with?
│ category Framework Starter
│
├ Which development framework do you want to use?
│ framework SvelteKit
│
├ Continue with SvelteKit via `npx sv@0.6.10 create my-svelte-app`
│

Need to install the following packages:
sv@0.6.10
Ok to proceed? (y) 

┌  Welcome to the Svelte CLI! (v0.6.10)
│
◇  Which template would you like?
│  SvelteKit minimal
│
◇  Add type checking with Typescript?
│  Yes, using Typescript syntax
│
◆  Project created
│
◇  What would you like to add to your project? (use arrow keys / space bar)
│  vitest
│
◇  Which package manager do you want to install dependencies with?
│  npm
│
◆  Successfully setup add-ons
│
◆  Successfully installed dependencies
│
◇  Project next steps ─────────────────────────────────────────────────────╮
│                                                                          │
│  1: cd my-svelte-app                                                     │
│  2: git init && git add -A && git commit -m "Initial commit" (optional)  │
│  3: npm run dev -- --open                                                │
│                                                                          │
│  To close the dev server, hit Ctrl-C                                     │
│                                                                          │
│  Stuck? Visit us at https://svelte.dev/chat                              │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
└  You're all set!


├ Copying template files
│ files copied to project directory
│
╰ Application created 

╭ Configuring your application for Cloudflare Step 2 of 3
│
├ Installing wrangler A command line tool for building Cloudflare Workers
│ installed via `npm install wrangler --save-dev`
│
├ Installing @cloudflare/workers-types
│ installed via npm
│
├ Adding latest types to `tsconfig.json`
│ added @cloudflare/workers-types/2023-07-01
│
├ Retrieving current workerd compatibility date
│ compatibility date 2025-01-09
│
├ Adding the Cloudflare Pages adapter
│ installed @sveltejs/adapter-cloudflare
│
├ Changing adapter in svelte.config.js
│
├ Updating global type definitions in app.d.ts
│
├ Adding Wrangler files to the .gitignore file
│ updated .gitignore file
│
├ Updating `package.json` scripts
│ updated `package.json`
│
├ Do you want to use git for version control?
│ no git
│
╰ Application configured 

╭ Deploy with Cloudflare Step 3 of 3
│
├ Do you want to deploy your application?
│ no deploy via `npm run deploy`
│
╰ Done 

────────────────────────────────────────────────────────────
🎉  SUCCESS  Application created successfully!

💻 Continue Developing
Change directories: cd my-svelte-app
Start dev server: npm run dev
Deploy: npm run deploy

📖 Explore Documentation
https://developers.cloudflare.com/workers

🐛 Report an Issue
https://github.com/cloudflare/workers-sdk/issues/new/choose

💬 Join our Community
https://discord.cloudflare.com
────────────────────────────────────────────────────────────


erikt@m1miniether cftest % ls
my-svelte-app
erikt@m1miniether cftest % cd my-svelte-app 
erikt@m1miniether my-svelte-app % ls
README.md		src			vite.config.ts
node_modules		static			wrangler.toml
package-lock.json	svelte.config.js
package.json		tsconfig.json
erikt@m1miniether my-svelte-app % npm run test

> my-svelte-app@0.0.1 test
> npm run test:unit -- --run


> my-svelte-app@0.0.1 test:unit
> vitest --run


 RUN  v2.1.8 /Users/erikt/cftest/my-svelte-app

 ✓ src/demo.spec.ts (1)
   ✓ sum test (1)
     ✓ adds 1 + 2 to equal 3

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  21:55:58
   Duration  331ms (transform 16ms, setup 0ms, collect 14ms, tests 2ms, environment 0ms, prepare 56ms)

close timed out after 10000ms
Tests closed successfully but something prevents Vite server from exiting
You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/config/#reporters

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that isn't workingvitestRelating to the Workers Vitest integration

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions