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

Vite dev server crashes if error is introduced in the Hono Server. #132

Closed
Blankeos opened this issue May 1, 2024 · 2 comments · Fixed by #138
Closed

Vite dev server crashes if error is introduced in the Hono Server. #132

Blankeos opened this issue May 1, 2024 · 2 comments · Fixed by #138

Comments

@Blankeos
Copy link

Blankeos commented May 1, 2024

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: vitejs/vite#12375

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.

Steps to reproduce:

  1. Clone and run this repo: https://github.com/Blankeos/spend-snap/tree/029cb1bbe64b17c05290b8399772ab60a94ec56b
  2. Introduce a syntax error anywhere in src/server/index.ts or _app.ts
  3. To run the server bun run dev:
    • Currently running it in node: vite
    • Can also run it in Bun bunx --bun vite
  4. 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.<computed> (/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.

@yusukebe
Copy link
Member

Hi @Blankeos

I've released @hono/[email protected] to fix this issue. Could you try it?

@Blankeos
Copy link
Author

@yusukebe Can confirm it works! Thanks so much!!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants