-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Describe the bug
Sveltekit throws an error when using navigation.cancel()
in beforeNavigate
:
<script>
import { beforeNavigate } from '$app/navigation';
beforeNavigate((navigation) => {
// this throws an error
navigation.cancel();
})
</script>
<a href="/other">Cancel navigation</a>
Not sure if this is expected behaviour, but the error is caught by our Sentry logging, which is kind of annoying when it's not really an error.
Reproduction
https://github.com/MathiasWP/sveltekit-navigation-cancel-repro
Logs
client.js?v=2cc7adfe:927 Uncaught (in promise) Error: navigation was cancelled
at Object.cancel (client.js?v=2cc7adfe:927:16)
at +page.svelte:5:20
at client.js?v=2cc7adfe:933:46
at Array.forEach (<anonymous>)
at before_navigate (client.js?v=2cc7adfe:933:30)
at navigate (client.js?v=2cc7adfe:969:15)
at HTMLHtmlElement.<anonymous> (client.js?v=2cc7adfe:1594:5)
### System Info
```Shell
System:
OS: macOS 13.5.1
CPU: (8) arm64 Apple M1 Pro
Memory: 53.38 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.9.0 - /usr/local/bin/node
npm: 9.1.1 - /usr/local/bin/npm
Browsers:
Brave Browser: 116.1.57.53
Chrome: 116.0.5845.140
Firefox: 112.0.2
Safari: 16.6
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.1.0
@sveltejs/kit: ^1.20.4 => 1.24.0
svelte: ^4.0.5 => 4.2.0
vite: ^4.4.2 => 4.4.9
Severity
annoyance
Additional Information
Most likely caused by this PR: #9605
Metadata
Metadata
Assignees
Labels
No labels