Skip to content

[Bug]: Dev server crashes when editing files #4789

@wfjsw

Description

@wfjsw

Version

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics         
    Memory: 5.54 GB / 27.86 GB
  Browsers:
    Edge: Chromium (131.0.2903.99)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @rsbuild/core: ^1.2.17 => 1.2.17 
    @rsbuild/plugin-react: ^1.1.1 => 1.1.1

Details

TanStack/router#3745

With Tanstack Router, when dev server is running and a file is saved halfway automatically, the dev server will crash by SyntaxError that is not gracefully handled. On Vite the error is thrown but no crash is happening.

♻️  Regenerating routes...
✅ Processed routes in 57ms
node_modules\@babel\parser\lib\index.js:360
    const error = new SyntaxError();
                  ^

SyntaxError: Unexpected token (287:4)
    at constructor (node_modules\@babel\parser\lib\index.js:360:19)
    at TypeScriptParserMixin.raise (node_modules\@babel\parser\lib\index.js:3327:19)
    at TypeScriptParserMixin.unexpected (node_modules\@babel\parser\lib\index.js:3347:16)
    at TypeScriptParserMixin.parseExprAtom (node_modules\@babel\parser\lib\index.js:11127:16)
    at TypeScriptParserMixin.parseExprAtom (node_modules\@babel\parser\lib\index.js:6936:20)
    at TypeScriptParserMixin.parseExprSubscripts (node_modules\@babel\parser\lib\index.js:10759:23)
    at TypeScriptParserMixin.parseUpdate (node_modules\@babel\parser\lib\index.js:10744:21)
    at TypeScriptParserMixin.parseMaybeUnary (node_modules\@babel\parser\lib\index.js:10724:23)
    at TypeScriptParserMixin.parseMaybeUnary (node_modules\@babel\parser\lib\index.js:9676:18)
    at TypeScriptParserMixin.parseMaybeUnaryOrPrivate (node_modules\@babel\parser\lib\index.js:10577:61) {
  code: 'BABEL_PARSER_SYNTAX_ERROR',
  reasonCode: 'UnexpectedToken',
  loc: Position { line: 287, column: 4, index: 8870 },
  pos: 8870,
  syntaxPlugin: undefined
}

In comparison, on Vite:

♻️  Regenerating routes...
2:10:14 AM [vite] (client) hmr update /src/routes/about.tsx, /src/styles.css
2:10:14 AM [vite] Internal server error: Unexpected token (13:4)
  Plugin: router-code-splitter-plugin
  File: /home/projects/zzmivyrrzz.github/src/routes/about.tsx:13:4
  11 |        <h3>About</h3>
  12 |        <
  13 |      </div>
     |      ^
  14 |    )
  15 |  }
      at constructor (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:360:19)
      at TypeScriptParserMixin.raise (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:3327:19)
      at TypeScriptParserMixin.unexpected (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:3347:16)
      at TypeScriptParserMixin.jsxParseIdentifier (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6741:12)
      at TypeScriptParserMixin.jsxParseNamespacedName (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6748:23)
      at TypeScriptParserMixin.jsxParseElementName (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6757:21)
      at TypeScriptParserMixin.jsxParseOpeningElementAt (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6833:22)
      at TypeScriptParserMixin.jsxParseElementAt (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6858:33)
      at TypeScriptParserMixin.jsxParseElementAt (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6870:32)
      at TypeScriptParserMixin.jsxParseElement (file:///home/projects/zzmivyrrzz.github/node_modules/@babel/parser/lib/index.js#cjs:6921:17)
✅ Processed routes in 60ms
 
♻️  Regenerating routes...

Reproduce link

https://stackblitz.com/edit/tanstack-router-wbdmzpmo

Reproduce Steps

Rsbuild won't work on Stackblitz, so this has to be downloaded

  1. Run npm i and then npm run dev
  2. Open src/routes/index.tsx
  3. Try to edit the JSX and save, for example add a < somewhere.
  4. Dev server crashes.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions