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

Log LOC for js syntax errors #6882

Closed
4 tasks done
j4k0xb opened this issue Nov 8, 2024 · 4 comments · Fixed by #6885 or vitejs/vite#18644
Closed
4 tasks done

Log LOC for js syntax errors #6882

j4k0xb opened this issue Nov 8, 2024 · 4 comments · Fixed by #6885 or vitejs/vite#18644
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@j4k0xb
Copy link

j4k0xb commented Nov 8, 2024

Clear and concise description of the problem

When a js file has a syntax error, the logs only indicate that it failed to parse but not where.

 FAIL  test/suite.test.js [ test/suite.test.js ]
Error: Expression expected
 ❯ getRollupError node_modules/rollup/dist/es/shared/parseAst.js:558:41
 ❯ convertProgram node_modules/rollup/dist/es/shared/parseAst.js:1246:26
 ❯ Module.parseAstAsync node_modules/rollup/dist/es/shared/parseAst.js:2232:106
 ❯ ssrTransformScript node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:52430:11

Suggested solution

Show the same overview as for TS files, or at least the line/column number

FAIL  test/basic.test.ts [ test/basic.test.ts ]
Error: Transform failed with 1 error:
/home/projects/vitest-dev-vitest-bdbgdx/test/basic.test.ts:29:1: ERROR: Unexpected end of file
  Plugin: vite:esbuild
  File: /home/projects/vitest-dev-vitest-bdbgdx/test/basic.test.ts:29:1
  
  Unexpected end of file
  27 |  });
  28 |  
  29 |  -
     |   ^
  
 ❯ failureErrorWithLog node_modules/esbuild/lib/main.js:1462:15
 ❯ eval node_modules/esbuild/lib/main.js:745:50
 ❯ responseCallbacks.<computed> node_modules/esbuild/lib/main.js:612:9
 ❯ handleIncomingPacket node_modules/esbuild/lib/main.js:667:12
 ❯ Socket.readFromStdout node_modules/esbuild/lib/main.js:590:7

Alternative

No response

Additional context

Use-case: simple editors like nano without syntax validation, automatically-generated test files

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Nov 8, 2024

This looks similar to vitejs/vite#16539 and that seems fixed recently. Which version of Vite do you have? Can you provide a repro?

(EDIT: Hmm, maybe not. It looks like Vite issue was only for build)

Copy link

github-actions bot commented Nov 8, 2024

Hello @j4k0xb. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@j4k0xb
Copy link
Author

j4k0xb commented Nov 8, 2024

Repro: https://stackblitz.com/edit/vitest-dev-vitest-yuxnbk?file=test%2Fsuite.test.js
It's using the latest vite (5.4.10) and vitest (2.1.4) as of now

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Nov 8, 2024

Thanks for reproduction. Probably we can reproduce this on normal Vite SSR and it should be fixed there.

Update: I made a Vite SSR repro https://stackblitz.com/edit/vitest-dev-vitest-wpj5mg?file=vite.config.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
2 participants