Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vite-node): don't exit on uncaughtException in watch mode #2186

Merged
merged 2 commits into from Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/vite-node/src/cli.ts
Expand Up @@ -84,6 +84,12 @@ async function run(files: string[], options: CliOptions = {}) {
server.emitter?.on('message', (payload) => {
handleMessage(runner, server.emitter, files, payload)
})

if (options.watch) {
process.on('uncaughtException', (err) => {
console.error(c.red('[vite-node] Failed to execute file: \n'), err)
})
}
}

function parseServerOptions(serverOptions: ViteNodeServerOptionsCLI): ViteNodeServerOptions {
Expand Down
2 changes: 1 addition & 1 deletion test/vite-node/package.json
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"test": "vitest",
"coverage": "vitest run --coverage",
"dev": "vite-node --watch ./src/*",
"dev": "vite-node --watch ./src/*.ts",
"debug:dev": "cross-env DEBUG=vite-node:* node --inspect-brk ../../packages/vite-node/dist/cli.cjs --watch ./src/*",
"debug": "node --inspect-brk ../../packages/vite-node/dist/cli.cjs"
},
Expand Down