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: parser error when conditionally rendering slot #388

Closed
1 task
thepassle opened this issue Apr 17, 2022 · 3 comments
Closed
1 task

🐛 BUG: parser error when conditionally rendering slot #388

thepassle opened this issue Apr 17, 2022 · 3 comments

Comments

@thepassle
Copy link

What version of astro are you using?

1.0.0-beta.8

Are you using an SSR adapter? If so, which one?

n/a

What package manager are you using?

npm

What operating system are you using?

mac

Describe the Bug

The following code leads to an unrecoverable error:

<div id="quiz-questions">
  {questions.map((question, questionId) => (
    <quiz-question client:visible>
      {question?.explanation && (<div slot="explanation">{question?.explanation}</div>)}
    </quiz-question>
  ))}
</div>

Error:

> astro dev

17:21:06 [warning] Warning:  SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.
  🚀  astro  v1.0.0-beta.11 started in 57ms
  
  ┃ Local    http://localhost:3000/
  ┃ Network  use --host to expose
  
  ▶ This is a  beta  prerelease build
    Feedback? https://astro.build/issues
  
Sourcemap for "/Users/au87xu/my-astro-course/node_modules/@lit-labs/ssr/lib/dom-shim.js" points to missing source files
panic: Element with a slot='...' attribute must be a child of a component or a descendant of a custom element

goroutine 13 [running]:
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d3590, {0x0, 0x1, 0x7, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:409 +0x533
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d33b0, {0x0, 0x1, 0x6, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:314 +0x2c5
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d31d0, {0x0, 0x1, 0x5, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:482 +0x4d8
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d2ff0, {0x0, 0x0, 0x4, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:314 +0x2c5
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d2e10, {0x0, 0x0, 0x3, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:549 +0x45b
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d2d20, {0x0, 0x0, 0x2, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:549 +0x45b
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d2b40, {0x0, 0x0, 0x1, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:549 +0x45b
github.com/withastro/compiler/internal/printer.render1(0x5e7b08, 0x5d2870, {0x1, 0x0, 0x0, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, ...}})
        github.com/withastro/compiler/internal/printer/print-to-js.go:99 +0x33
github.com/withastro/compiler/internal/printer.printToJs(0x5e7b08, 0x5d2870, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, {0x4be8e0, 0x1a}, {0x436960, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:74 +0x2
github.com/withastro/compiler/internal/printer.PrintToJS({0x4cea80, 0x165}, 0x5d2870, 0x0, {{0x56de70, 0x8}, {0x4bd140, 0x37}, {0x4be8e0, 0x1a}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:49 +0xc
main.Transform.func1.1.1({0x4cea80, 0x165}, 0x4483f0, {{}, 0x7ff800040000007d, 0x56dee8})
        ./astro-wasm.go:240 +0x29
created by main.Transform.func1.1
        ./astro-wasm.go:183 +0x3
exit code: 2
Go program has already exited
Go program has already exited
Error: Uh oh, the Astro compiler encountered an unrecoverable error!
    
    Please open
    a GitHub issue using the link below:
    https://github.com/withastro/astro/issues/new?labels=compiler&title=%F0%9F%90%9B+BUG%3A+%60%40astrojs%2Fcompiler%60+panic&body=%23%23%23+Describe+the+Bug%0A++++%0A++++%60%40astrojs%2Fcompiler%60+encountered+an+unrecoverable+error+when+compiling+the+following+file.%0A++++%0A++++**src%2Fcomponents%2FQuiz.astro**%0A++++%60%60%60astro%0A++++---%0Aimport+%27.%2Fquiz-question.js%27%3B%0Aimport+%27.%2Fquiz-next-card.js%27%3B%0Aconst+%7B+next%2C+nextLink%2C+questions%2C+title+%7D+%3D+Astro.props%3B+%0A---%0A%0A%3Cdiv+id%3D%22quiz-questions%22%3E%0A++%7Bquestions.map%28%28question%2C+questionId%29+%3D%3E+%28%0A++++%3Cquiz-question+client%3Avisible%3E%0A++++++%7Bquestion%3F.explanation+%26%26+%28%3Cdiv+slot%3D%22explanation%22%3E%7Bquestion%3F.explanation%7D%3C%2Fdiv%3E%29%7D%0A++++%3C%2Fquiz-question%3E%0A++%29%29%7D%0A%0A%3C%2Fdiv%3E%0A%0A++++%60%60%60%0A++++
Go program has already exited
17:21:08 [vite] Error when evaluating SSR module /node_modules/astro/components/index.js?v=09d0b2ea:
Error: Go program has already exited
    at Go._resume (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/wasm_exec.js:435:19)
    at Object.transform (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/wasm_exec.js:447:16)
    at file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:41:82
    at new Promise (<anonymous>)
    at Object.transform (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:41:40)
    at file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:5:51
17:21:08 [vite] Error when evaluating SSR module /Users/au87xu/my-astro-course/src/pages/sw/[...a]/index.astro:
Error: Go program has already exited
    at Go._resume (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/wasm_exec.js:435:19)
    at Object.transform (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/wasm_exec.js:447:16)
    at file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:41:82
    at new Promise (<anonymous>)
    at Object.transform (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:41:40)
    at file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:5:51
 error   Go program has already exited
    at Go._resume (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/wasm_exec.js:435:19)
    at Object.transform (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/wasm_exec.js:447:16)
    at file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:41:82
    at new Promise (<anonymous>)
    at Object.transform (file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:41:40)
    at file:///Users/au87xu/my-astro-course/node_modules/@astrojs/compiler/node/index.js:5:51
Go program has already exited
Go program has already exited

Link to Minimal Reproducible Example

astro.new

Participation

  • I am willing to submit a pull request for this issue.
@thepassle thepassle changed the title 🐛 BUG: 🐛 BUG: parser error when conditionally rendering slot Apr 17, 2022
@bholmesdev
Copy link

Seems this issue is lit-specific. Mind sharing a link to a reproducible example @thepassle? This link should pull up an Astro + lit playground

@Jutanium
Copy link

Jutanium commented May 4, 2022

This is not lit specific, see #383

@natemoo-re
Copy link
Member

Confirming that this has been closed by #447 and is now working! Here's a repro.

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

No branches or pull requests

5 participants