Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of null (reading 'name') at Activity.svelte:9:16` #1

Closed
mipodi opened this issue Apr 26, 2022 · 4 comments

Comments

@mipodi
Copy link
Contributor

mipodi commented Apr 26, 2022

  1. Have both sanity studio and svelte up and running
  2. Navigate in the browser to an activity

This error is thrown in the terminal (the svelte process):
TypeError: Cannot read properties of null (reading 'name') at Activity.svelte:9:16

the line in question

Tried to comment out the line and also restart the process but it still indicates an error there (how can it be?). Not sure how <svelte:head>works, should Activity be initiated/called there as well, as the one below <Activity {activity} />?

@mipodi mipodi added the help wanted Extra attention is needed label Apr 26, 2022
@zamzterz
Copy link
Collaborator

Hmm, I can't reproduce that. 🤔
Just tested with http://localhost:3000/activities/say-hello-to-nasims-cat.
Any changes on your end? And you could see it before, right?

From the error message it sounds like it's not getting any data from Sanity, i.e.

is empty.
Not sure how or why that might be...
Do you see anything in the network tab of your browser, i.e. is there some HTTP request that is not 200 OK?

  • <svelte:head> contains the content to add in the HTML element (which happens here).
  • <Activity {activity} /> is a custom component (defined here) intended to render the full data of an activity, so shouldn't go in the head content.

@mipodi
Copy link
Contributor Author

mipodi commented Apr 27, 2022

The page is always visible in the browser so I first didn't notice the error.

Ah! Via the network tab I get
favicon.png:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Hehe, sneaky little favicon. The favicon is referenced in the head, so there we have it. However, the favicon is visible in the browser tab, so it can be found... hmm.

The error only occurs (in the terminal) when I click on an activity on the start page and go to the activity page. It does not occur when I reload the activity page. If I comment out the favicon request there is no error.

The full error
Cannot read properties of null (reading 'name') TypeError: Cannot read properties of null (reading 'name') at [slug].svelte:9:19 at Object.$$render (/Users/burken/Kodprojekt/myko/myko/node_modules/svelte/internal/index.js:1745:22) at Object.default (root.svelte:43:39) at eval (/.svelte-kit/runtime/components/layout.svelte:8:41) at Object.$$render (/Users/burken/Kodprojekt/myko/myko/node_modules/svelte/internal/index.js:1745:22) at root.svelte:37:37 at $$render (/Users/burken/Kodprojekt/myko/myko/node_modules/svelte/internal/index.js:1745:22) at Object.render (/Users/burken/Kodprojekt/myko/myko/node_modules/svelte/internal/index.js:1753:26) at render_response (file:///Users/burken/Kodprojekt/myko/myko/.svelte-kit/runtime/server/index.js:1223:27) at processTicksAndRejections (node:internal/process/task_queues:96:5)

It could be the same as
sveltejs/kit#3234 (comment)

but they say

(Note that there's currently a bug around paths.base — static assets aren't served from there in dev mode. Needs fixing separately.)

Maybe we send this problem to our future selves? Maybe we want the favicon(s) served via Sanity CDN.

@zamzterz
Copy link
Collaborator

That's some good digging!

For me the favicon shows up in the browser and I don't see any error.
But I see your commit and agree, let's ignore it for now 😇

@mipodi mipodi removed the help wanted Extra attention is needed label Apr 27, 2022
@mipodi
Copy link
Contributor Author

mipodi commented Apr 27, 2022

Okidoki 😄

@mipodi mipodi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants