sapper icon indicating copy to clipboard operation
sapper copied to clipboard

Updates to the session store when rendering _error.svelte causes a TypeError

Open AaronDDM opened this issue 4 years ago • 0 comments
trafficstars

Describe the bug If you are on a 404 page handled by Sapper and your code (e.g. in the _layout.svelte file) updates the session store, you'll notice a TypeError in your console logs.

Logs

Uncaught (in promise) TypeError: Cannot destructure property 'route' of 'dest' as it is undefined.

To Reproduce https://github.com/AaronDDM/sapper-store-update-bug/blob/main/src/routes/_layout.svelte

  1. Check out the above repo
  2. Start your server via npm run dev
  3. Visit a URL that does not exist (e.g. http://localhost:3000/ARouteThatDoesNotExist)
  4. Open your browser console logs
  5. Refresh the page

Expected behavior No type error.

Stacktraces If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread's readability:

Stack trace
  (anonymous) @ app.mjs:455
  (anonymous) @ app.mjs:28
  __awaiter @ app.mjs:24
  hydrate_target @ app.mjs:454
  (anonymous) @ app.mjs:334
  (anonymous) @ app.mjs:28
  __awaiter @ app.mjs:24
  (anonymous) @ app.mjs:327
  set @ index.mjs:35
  update @ index.mjs:43
  (anonymous) @ _layout.svelte:11
  Promise.then (async)    
  step @ app.mjs:27
  (anonymous) @ app.mjs:28
  __awaiter @ app.mjs:24
  (anonymous) @ app.mjs:327
  set @ index.mjs:35
  update @ index.mjs:43
  (anonymous) @ _layout.svelte:11
  setTimeout (async)    
  instance$2 @ _layout.svelte:10
  init$1 @ index.mjs:1474
  Layout @ _layout.svelte:17
  create_fragment @ App.svelte:20
  init$1 @ index.mjs:1489
  App @ App.svelte:17
  (anonymous) @ app.mjs:424
  fulfilled @ app.mjs:25
  Promise.then (async)    
  step @ app.mjs:27
  (anonymous) @ app.mjs:28
  __awaiter @ app.mjs:24
  render @ app.mjs:408
  handle_error @ app.mjs:382
  (anonymous) @ app.mjs:354
  Promise.then (async)    
  start$1 @ app.mjs:353
  (anonymous) @ client.js:3

AaronDDM avatar Mar 23 '21 17:03 AaronDDM