-
Notifications
You must be signed in to change notification settings - Fork 644
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
Errors thrown within <await><@catch> are not handled #1813
Comments
This definitely seems like it should work, but we may have to make the fix back-compat friendly. We're figuring out how. |
Another point to add to your thinking: I find myself adding the following (in addition to the patch above)
It seems that I need to add in another This last bit, (the flushing of chunks) is somewhat guess work at this point, I haven't dug deep enough into the code yet. So, I could be wrong entirely! Apologies if this causes a wild goose chase! |
@vwong what issue are you having with the null chunk being flushed with the rest of the await? |
FYI @mlrawlings was floating the idea of having something like: <@catch|err| rethrow> However I think if this manual throw case isn't working it probably should also. |
If I just had:
The stream, in some cases, completes fine (with the patch applied), with null terminating chunk and all. I haven't had time to dig into exactly why, but I suspect this happens when this is already the last That's why I attempted to inject another dummy
I was hoping that this would cause the stream to pause, enough for it to disconnect before the null chunk. In my testing, this seems to work. I've been thinking about A better end-result, I think, is to continue rendering the rest of the page, but keep track that an error occurred at all, then corrupt the page right at the end. But I'd accept the mid-stream termination if we can't achieve the near-end-termination. |
Looks like this is now handled by #2005. |
Marko Version
5.21.2
Details
In an
<await>
tag, if I don't specify the<@catch>
, then the error is forwarded to the server (ExpressJS, in my case), so that the server can handle it correctly - such as prematurely terminating the response stream, so that clients know the response is bad. If I do specify the<@catch>
, then the error is swallowed, and not forwarded to the server; as far as the stream is concerned, nothing is wrong.I want to be able to render a user-friendly message AND indicate to the server to terminate the response stream.
I try re-throwing the error...
Expected Behavior
Thrown error is handled, and does not crash the server
Actual Behavior
Error is uncaught, and crashes the server (makes it unresponsive)
Possible Fix
Handle the (re) thrown error (or any other newly thrown one), the same way as if when there was no
<@catch>
.I'm happy to help create a PR to fix this (with the appropriate tests), if this is deemed desirable and correct.
The text was updated successfully, but these errors were encountered: