From 87ed0b2f427fa6552feafcf05c39c40e27ec80fb Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Tue, 15 Sep 2020 21:13:50 +0800 Subject: [PATCH] fix await stuck indefinitely without catch (#5402) --- CHANGELOG.md | 1 + src/runtime/internal/await_block.ts | 6 +++--- test/runtime/samples/await-without-catch/_config.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c9922a086..bc8272f84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Fix transitions that are parameterised with stores ([#5244](https://github.com/sveltejs/svelte/issues/5244)) * Fix scoping of styles involving child selector and `*` ([#5370](https://github.com/sveltejs/svelte/issues/5370)) * Fix destructuring which reassigns stores ([#5388](https://github.com/sveltejs/svelte/issues/5388)) +* Fix `{#await}`s with no `{:catch}` getting stuck unresolved if the promise rejects ([#5401](https://github.com/sveltejs/svelte/issues/5401)) ## 3.25.0 diff --git a/src/runtime/internal/await_block.ts b/src/runtime/internal/await_block.ts index 3821520837..4b7ca6fd21 100644 --- a/src/runtime/internal/await_block.ts +++ b/src/runtime/internal/await_block.ts @@ -59,12 +59,12 @@ export function handle_promise(promise, info) { update(info.then, 1, info.value, value); set_current_component(null); }, error => { - if (!info.hasCatch) { - throw error; - } set_current_component(current_component); update(info.catch, 2, info.error, error); set_current_component(null); + if (!info.hasCatch) { + throw error; + } }); // if we previously had a then/catch block, destroy it diff --git a/test/runtime/samples/await-without-catch/_config.js b/test/runtime/samples/await-without-catch/_config.js index 2030ed7949..1b7da5c0be 100644 --- a/test/runtime/samples/await-without-catch/_config.js +++ b/test/runtime/samples/await-without-catch/_config.js @@ -39,6 +39,7 @@ export default { }) .catch((err) => { assert.equal(err.message, 'this error should be thrown'); + assert.htmlEqual(target.innerHTML, ''); }); } }; \ No newline at end of file