Skip to content

Error when navigating from a svelte page to an endpoint #867

@acoyfellow

Description

@acoyfellow

Describe the bug
When on a .svelte route, if you have a link that points to a server endpoint (my use case: generating a .pdf), you see an error fom start.js on the svelte route before navigating away, and it breaks the back button. I can reproduce on a couple different machines, in dev, and in build/production.

Logs

Uncaught (in promise) TypeError: Cannot read property 'nodes' of undefined
    at Renderer.update (.svelte/dev/runtime/internal/start.js:497)
    at async Router._navigate (.svelte/dev/runtime/internal/start.js:248)

To Reproduce

  1. start with fresh sveltekit install
  2. create /src/routes/test:
export async function get() {
  return { body: {} }
};
  1. modify the src/routes/index.svelte:
    <p>Visit <a href="/test">/test</a> to see the problem.</p>
  2. npm run dev - visit the homepage, open js console, click /test, notice debugger.

Expected behavior
I'd expect it to not throw an error, and not break "back" functionality

Stacktraces

​ Uncaught (in promise) TypeError: Cannot read property 'nodes' of undefined
    at Renderer.update (.svelte/dev/runtime/internal/start.js:497)
    at async Router._navigate (.svelte/dev/runtime/internal/start.js:248)
update @ .svelte/dev/runtime/…ternal/start.js:497
async function (async)
_navigate @ .svelte/dev/runtime/…ternal/start.js:248
(anonymous) @ .svelte/dev/runtime/…ternal/start.js:141

Information about your SvelteKit Installation:

Diagnostics
System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
    Memory: 2.98 GB / 7.78 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
    npm: 7.8.0 - ~/.nvm/versions/node/v14.16.0/bin/npm
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.71 
    svelte: ^3.29.0 => 3.37.0 
    vite: ^2.1.0 => 2.1.5 
  • Tried in Chrome, Firefox, Safari - all show the bug.
  • adapter: @sveltejs/adapter-node

Severity
Minor. Add rel="external" to the link and it side-steps this problem

Additional context
@GrygrFlzr said he could not reproduce this, so i'm not 100% confident this isn't something else I'm doing wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrouter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions