You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(This came out of sveltejs/kit#2520 but is a separate matter from how SvelteKit ought to deal with user code that creates unhandled rejected promises.)
Node 16 terminates the process immediately when it detects that a dangling promise has rejected and no callbacks have been attached to handle that. SSR code for an {#await} block ignores the promise resolution (and just renders the waiting-for-promise content), which means that Node thinks the promise has not been handled appropriately. In Node 14, this results in a noisy warning, and in Node 16 this results in the program ending with an error.
Since we specifically do not care about the promise resolution/rejection in SSR in {#await}s (and since there's nothing we can do about this while SSR itself is synchronous), the generated SSR code for an {#await} block should contain explicit (dummy) handlers for the promise, to appease Node.
Reproduction
{#awaitPromise.reject('foo')}
bar
{/await}
Compiling this in SSR mode and running it in Node 16 results in the process crashing, because you are generating a promise that rejects but it is then never handled.
Logs
[UnhandledPromiseRejection: This error originated either by throwing inside of an async functionwithout a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "foo".] {
code: 'ERR_UNHANDLED_REJECTION'
}
System Info
Node: 16.10.0
Severity
annoyance
The text was updated successfully, but these errors were encountered:
Describe the bug
(This came out of sveltejs/kit#2520 but is a separate matter from how SvelteKit ought to deal with user code that creates unhandled rejected promises.)
Node 16 terminates the process immediately when it detects that a dangling promise has rejected and no callbacks have been attached to handle that. SSR code for an
{#await}
block ignores the promise resolution (and just renders the waiting-for-promise content), which means that Node thinks the promise has not been handled appropriately. In Node 14, this results in a noisy warning, and in Node 16 this results in the program ending with an error.Since we specifically do not care about the promise resolution/rejection in SSR in
{#await}
s (and since there's nothing we can do about this while SSR itself is synchronous), the generated SSR code for an{#await}
block should contain explicit (dummy) handlers for the promise, to appease Node.Reproduction
Compiling this in SSR mode and running it in Node 16 results in the process crashing, because you are generating a promise that rejects but it is then never handled.
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: