Skip to content

Commit

Permalink
feat(vite-node): don't exit on uncaughtException in watch mode (#2186)
Browse files Browse the repository at this point in the history
* feat: dont exit when uncaughtException

* chore: update

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
poyoho and antfu committed Oct 25, 2022
1 parent bd8b4e3 commit dc00ae7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit dc00ae7

Please sign in to comment.