schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs, SSR and SSG.
https://jasprpad.schultek.de
MIT License
1.07k stars 65 forks source link

fix: Jaspr does not properly return a 500 error when an error occurs durring rendering #129

Closed fuzzybinary closed 4 months ago

fuzzybinary commented 10 months ago

Description

If a widget throws an exception during rendering (for example during preloadState) the exception is not bubbled up to shelf, and thus no response is sent to the browser, which looks in Firefox to just be an infinite load.

Steps To Reproduce

Doctor Output

[✓] Jaspr CLI (Version 0.9.2) • Dart Version 3.1.3 (stable) (Tue Sep 26 14:25:13 2023 +0000) on "windows_x64" at C:\Users\Jeff Ward\Projects\flutter\bin\cache\dart-sdk\bin\dart.exe • Running on windows "Windows 10 Home Single Language" 10.0 (Build 19045) - Locale en-US • Analytics: Enabled

[✓] Current Project • Dependencies on core packages: • jaspr: ^0.9.2 • jaspr_builder: ^0.9.2 (dev) • jaspr_router: ^0.3.0 • Uses server-side rendering: true • Uses experimental compilers: false • Uses flutter embedding: false

Expected Behavior

Server should properly return a 500 error.

Additional Context

This is because the Isolate.spawn does not automatically propagate error back to the calling isolate. I have a fix locally, and I'll work on getting a PR up in the next few days if you're open to it.

schultek commented 7 months ago

Sry this one slipped through my radar. I'm happy to accept a PR for this, definitely important to do proper error handling.