Skip to content

Commit 8ddcbc4

Browse files
committed
fulfil promise after redirect has occurred
1 parent b2bc0c8 commit 8ddcbc4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/kit/src/runtime/client/client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ export async function _goto(url, options, redirect_count, nav_token) {
461461
load_cache = null;
462462
}
463463

464-
const result = await navigate({
464+
await navigate({
465465
type: 'goto',
466466
url: resolve_url(url),
467467
keepfocus: options.keepFocus,
@@ -481,6 +481,7 @@ export async function _goto(url, options, redirect_count, nav_token) {
481481
}
482482
}
483483
});
484+
484485
if (options.invalidateAll) {
485486
// TODO the ticks shouldn't be necessary, something inside Svelte itself is buggy
486487
// when a query in a layout that still exists after page change is refreshed earlier than this
@@ -496,7 +497,6 @@ export async function _goto(url, options, redirect_count, nav_token) {
496497
});
497498
});
498499
}
499-
return result;
500500
}
501501

502502
/** @param {import('./types.js').NavigationIntent} intent */
@@ -1283,6 +1283,7 @@ async function load_root_error_page({ status, error, url, route }) {
12831283
});
12841284
} catch (error) {
12851285
if (error instanceof Redirect) {
1286+
// @ts-expect-error TODO investigate this
12861287
return _goto(new URL(error.location, location.href), {}, 0);
12871288
}
12881289

@@ -1577,7 +1578,7 @@ async function navigate({
15771578
if (navigation_result.type === 'redirect') {
15781579
// whatwg fetch spec https://fetch.spec.whatwg.org/#http-redirect-fetch says to error after 20 redirects
15791580
if (redirect_count < 20) {
1580-
return navigate({
1581+
await navigate({
15811582
type,
15821583
url: new URL(navigation_result.location, url),
15831584
popped,
@@ -1588,6 +1589,9 @@ async function navigate({
15881589
redirect_count: redirect_count + 1,
15891590
nav_token
15901591
});
1592+
1593+
nav.fulfil(undefined);
1594+
return;
15911595
}
15921596

15931597
navigation_result = await load_root_error_page({

0 commit comments

Comments
 (0)