If you run vite dev then introduce a syntax error in index.ts and any of the files that are running the Hono server, the dev server crashes and fails to restart, and the process crashes.
Ideally the process would stay alive, and gracefully recover once the error is fixed. Even better would be if the server survived, if only to report the error, though that's probably somewhat trickier.
Introduce a syntax error anywhere in src/server/index.ts or _app.ts
To run the server bun run dev:
Currently running it in node: vite
Can also run it in Bun bunx --bun vite
Either way, try introducing an error AND both would still crash the dev server without restarts.
System
System Info
System:
OS: macOS 14.4.1
Binaries:
Bun: 1.1.6
Error vite
View Error
```
9:03:50 PM [vite] page reload src/server/_app.ts
[vite] program reload
/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:1651
let error = new Error(text);
^
Error: Transform failed with 1 error:
/Users/carlo/Desktop/Projects/spend-snap/src/server/_app.ts:13:35: ERROR: Expected ")" but found ";"
at failureErrorWithLog (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:1651:15)
at /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:849:29
at responseCallbacks. (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:704:9)
at handleIncomingPacket (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:764:9)
at Socket.readFromStdout (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:680:7)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Socket.Readable.push (node:internal/streams/readable:390:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)
error: script "dev" exited with code 1
```
Error bunx --bun vite
View Error
```
9:16:57 PM [vite] page reload src/server/modules/collations/collations.controller.ts
[vite] program reload
1646 | let { file, line, column } = e.location;
1647 | let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : "";
1648 | return `
1649 | ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
1650 | }).join("");
1651 | let error = new Error(text);
^
error: Transform failed with 1 error:
/Users/carlo/Desktop/Projects/spend-snap/src/server/modules/collations/collations.controller.ts:4:30: ERROR: Expected ";" but found "("
errors: [
{
"id": "",
"location": {
"column": 30,
"file": "/Users/carlo/Desktop/Projects/spend-snap/src/server/modules/collations/collations.controller.ts",
"length": 1,
"line": 4,
"lineText": "export const collationsControl().basePath(\"/collations\");",
"namespace": "",
"suggestion": ";"
},
"notes": [],
"pluginName": "",
"text": "Expected \";\" but found \"(\""
}
]
at failureErrorWithLog (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:1651:15)
at /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:849:29
at /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:704:9
at handleIncomingPacket (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:764:9)
at readFromStdout (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:680:7)
at addChunk (node:stream:1953:43)
at readableAddChunk (node:stream:1907:59)
at node:stream:32:101
at node:stream:125:103
error: script "dev" exited with code 1
```
The errors aren't really important. It's the fact that it closes when there's an error.
If you run
vite dev
then introduce a syntax error in index.ts and any of the files that are running the Hono server, the dev server crashes and fails to restart, and the process crashes.Somewhat same motivations as in Rich's words from this issue: https://github.com/vitejs/vite/issues/12375
Steps to reproduce:
src/server/index.ts
or_app.ts
bun run dev
:vite
bunx --bun vite
System
Error
vite
View Error
``` 9:03:50 PM [vite] page reload src/server/_app.ts [vite] program reload /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:1651 let error = new Error(text); ^ Error: Transform failed with 1 error: /Users/carlo/Desktop/Projects/spend-snap/src/server/_app.ts:13:35: ERROR: Expected ")" but found ";" at failureErrorWithLog (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:1651:15) at /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:849:29 at responseCallbacks.Error
bunx --bun vite
View Error
``` 9:16:57 PM [vite] page reload src/server/modules/collations/collations.controller.ts [vite] program reload 1646 | let { file, line, column } = e.location; 1647 | let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : ""; 1648 | return ` 1649 | ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`; 1650 | }).join(""); 1651 | let error = new Error(text); ^ error: Transform failed with 1 error: /Users/carlo/Desktop/Projects/spend-snap/src/server/modules/collations/collations.controller.ts:4:30: ERROR: Expected ";" but found "(" errors: [ { "id": "", "location": { "column": 30, "file": "/Users/carlo/Desktop/Projects/spend-snap/src/server/modules/collations/collations.controller.ts", "length": 1, "line": 4, "lineText": "export const collationsControl().basePath(\"/collations\");", "namespace": "", "suggestion": ";" }, "notes": [], "pluginName": "", "text": "Expected \";\" but found \"(\"" } ] at failureErrorWithLog (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:1651:15) at /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:849:29 at /Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:704:9 at handleIncomingPacket (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:764:9) at readFromStdout (/Users/carlo/Desktop/Projects/spend-snap/node_modules/vite/node_modules/esbuild/lib/main.js:680:7) at addChunk (node:stream:1953:43) at readableAddChunk (node:stream:1907:59) at node:stream:32:101 at node:stream:125:103 error: script "dev" exited with code 1 ```The errors aren't really important. It's the fact that it closes when there's an error.