withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.53k stars 2.47k forks source link

🐛 BUG: 500 error page not rendering #1420

Closed Tc-001 closed 2 years ago

Tc-001 commented 3 years ago

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

Error 500 nicely formatted page is not being rendered, instead returns the error message in the form of plaintext.

Steps to Reproduce

  1. npm init astro using any template
  2. make an error
  3. Bug! You will be presented with an empty page and the error printed at the top. image

this can be demonstrated by using curl against a failing page

me@me ~> curl http://localhost:3000/
SyntaxError: Missing semicolon. (2:6)⏎

versus a working one

me@me ~> curl http://localhost:3000/en/introduction
<!doctype html><html dir="ltr" lang="en-us" class="initial"><head>...

Expected: It should render https://github.com/snowpackjs/astro/blob/main/packages/astro/src/frontend/500.astro

Link to Minimal Reproducible Example (Optional)

https://codesandbox.io/s/brave-ptolemy-nr1f6?file=/src/pages/index.astro

Tc-001 commented 3 years ago

From my investigation, it seems that the rendering took place in a file called "search.ts", and was added here: https://github.com/snowpackjs/astro/blob/573f3a7e13d006848e7c3b706d7753b2520ae245/src/search.ts#L94-L103

After that, it got deleted when adding dynamic paths (https://github.com/snowpackjs/astro/pull/1010/files#diff-9434205e3d2df3939080dffb063f23ab91a19322436ad755f0b0abd2f6b1b786) with the functionality seemingly not re-added

matthewp commented 3 years ago

Thanks! As @Tc-001 pointed out the logic didn't get ported over when the routing changed. However it's changing against in the next branch and we do have HTML based error messages: https://github.com/snowpackjs/astro/blob/f0839c62df45c71774a6fbbe6fcbaae97f98c6bb/packages/astro/src/dev/template/error.ts#L11

Going to mark this as blocked, then we can verify it once next is ready.

FredKSchott commented 2 years ago

Thanks for the report! We believe that this has been fixed in astro v0.21, going out today. Let us know if you can still reproduce the issue after updating to v0.21 and we'll be happy to take a look.