-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[fix] handle promise rejections for {#await} in SSR #6790
Conversation
The tests are passing without this change because of Lines 28 to 30 in 3f990a9
The runtime (browser) tests are listening for this event, which is preventing it from causing a crash anywhere else. I'm experimenting with having tests be responsible for detaching the |
@@ -13,7 +13,10 @@ export default function(node: AwaitBlock, renderer: Renderer, options: RenderOpt | |||
|
|||
renderer.add_expression(x` | |||
function(__value) { | |||
if (@is_promise(__value)) return ${pending}; | |||
if (@is_promise(__value)) { | |||
__value.then(() => {}, () => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be .catch
instead of .then
? (i'm assuming you're right and I don't understand this, but just making sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's .then(() => {}, () => {})
, which attaches a resolve and a reject handler. This seems microscopically safer than .catch(() => {})
, because all is_promise
has actually confirmed is that the value is an object with a then
method. If it's a proper promise, we should be able to use .catch
as well, but .then
should also be equivalent.
The |
Fixes #6789. I haven't looked yet at how reasonable they would be to write. We aren't running any tests in Node 16 in CI, but I'm a little surprised that none of the tests involving SSR and
{#await}
are currently failing for me when running them locally. I'm not sure how else I'd cause a breakage that I could then demonstrate was fixed by this PR.Before submitting the PR, please make sure you do the following
[feat]
,[fix]
,[chore]
, or[docs]
.Tests
npm test
and lint the project withnpm run lint