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

🐛 BUG: astro check cannot parse file #870

Open
reisi007 opened this issue May 14, 2024 · 3 comments
Open

🐛 BUG: astro check cannot parse file #870

reisi007 opened this issue May 14, 2024 · 3 comments
Labels
- P2: has workaround Bug, but has workaround (priority) ecosystem: compiler Issue is caused by a bug in the Astro compiler

Comments

@reisi007
Copy link

reisi007 commented May 14, 2024

Describe the Bug

error astro(1000): The Astro compiler encountered an unknown error while transform this file to TSX. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/language-tools/issues

WORKING Pagination.astro

Steps to Reproduce

The Astro JSX compiler has a problem parsing this file.

Only effects Astro check, astro build is fine and the generated files seem to be working just fine....

FAILING Pagination.astro

`panic: runtime error: index out of range [0] with length 0

goroutine 6 [running]:
github.com/withastro/compiler/internal/printer.renderTsx(0x1413950, 0x15623c0)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:248 +0x1b6
github.com/withastro/compiler/internal/printer.renderTsx(0x1413950, 0x1562140)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f
github.com/withastro/compiler/internal/printer.renderTsx(0x1413950, 0x14c9e00)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f
github.com/withastro/compiler/internal/printer.renderTsx(0x1413950, 0x14c9b80)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f
github.com/withastro/compiler/internal/printer.renderTsx(0x1413950, 0x14c9900)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f
github.com/withastro/compiler/internal/printer.renderTsx(0x1413950, 0x14c9540)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:147 +0xba
github.com/withastro/compiler/internal/printer.PrintToTSX({0x152b200, 0x409}, 0x14c9540, {{0x3c3c4, 0x6}, {0x145c6e0, 0x42}, {0x145c6e0, 0x42}, {0x46f38, ...}, ...}, ...)
github.com/withastro/compiler/internal/printer/print-to-tsx.go:30 +0x12
main.main.ConvertToTSX.func3({{}, 0x7ff800010000004b, 0x140c500}, {0x1434200, 0x2, 0x2})
./astro-wasm.go:263 +0xe
syscall/js.handleEvent()
syscall/js/func.go:100 +0x23
exit code: 2
There was an error transforming d:/Github/astro-reisinger.pictures/src/components/Pagination.astro to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues
Error: TypeError: Cannot read properties of undefined (reading 'map').
D:\Github\astro-reisinger.pictures\node_modules@astrojs\compiler\dist\node\sync.cjs:1
`

"astro": "^4.8.3"

@github-actions github-actions bot added the needs triage Issue needs to be triaged label May 14, 2024
@reisi007 reisi007 changed the title 🐛 BUG: 🐛 BUG: astro check cannot parse file May 14, 2024
@Princesseuh Princesseuh added the ecosystem: compiler Issue is caused by a bug in the Astro compiler label May 15, 2024
@wolf-yuan-6115
Copy link

I'm having the same issue, but not when running astro check, it happens when editing files on Neovim.

A video is attached.

Screencast.from.2024-05-31.14-24-55.mp4

@Princesseuh Princesseuh added needs repro Issue needs a reproduction ecosystem: compiler Issue is caused by a bug in the Astro compiler and removed ecosystem: compiler Issue is caused by a bug in the Astro compiler needs triage Issue needs to be triaged needs repro Issue needs a reproduction labels May 31, 2024
@withastro withastro deleted a comment from github-actions bot May 31, 2024
@Princesseuh
Copy link
Member

In the file in the OP, the issue is that the closing tag on line 16 has an extra space:

<a class:list={
  ['col-start-1 border-2 hover:border-primary-accent border-primary-alternative flex items-center',
   ' justify-center size-8 rounded-full', {'hidden': !prev}]
- } href={prev}> <span class="i-mdi-arrow-left"> </ span>
+ } href={prev}> <span class="i-mdi-arrow-left"> </span>
</a>

Upstream issue: withastro/compiler#1007

@Princesseuh Princesseuh added the - P2: has workaround Bug, but has workaround (priority) label May 31, 2024
@wolf-yuan-6115
Copy link

In the file in the OP, the issue is that the closing tag on line 16 has an extra space:

<a class:list={
  ['col-start-1 border-2 hover:border-primary-accent border-primary-alternative flex items-center',
   ' justify-center size-8 rounded-full', {'hidden': !prev}]
- } href={prev}> <span class="i-mdi-arrow-left"> </ span>
+ } href={prev}> <span class="i-mdi-arrow-left"> </span>
</a>

Upstream issue: withastro/compiler#1007

My code doesn't contain any whitespace in closing tags, so I'll investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) ecosystem: compiler Issue is caused by a bug in the Astro compiler
Projects
None yet
Development

No branches or pull requests

3 participants