vercel/speed-insights

SvelteKit - TypeError: Cannot Read properties of undefined (reading: 'id")

ninicdennis opened this issue ยท 6 comments

When including the new speed insights package into my application, Inside of the app, content stops loading and I see the following error 3 times in my console:

TypeError: Cannot read properties of undefined (reading 'id')
    at injectSpeedInsights2 (@vercel_speed-insights_sveltekit.js?v=49aa9ded:88:41)
    at +layout.ts:5:1

The application does have analytics and speed insights both enabled.

Hello @ninicdennis, and thanks for the feedback.
In order to help us fixing it as quickly as possible, could you share a minimal reproduction please?

Same problem here. I just did what is said in the documentation, add the following code to +layout.ts file:

import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit'
injectSpeedInsights()

One thing I notice: The error occurs when I call the injectSpeedInsights() function in +layout.ts file, if I call it inside a onMount() function in +layout.svelte, it runs successfully. +layout.ts file runs in both server and client, but it shows error in the client as well, the error that is not shown in onMount() function. Don't know why.

Than you gents. we indeed always tried it in the <script> markup of a +layout.svelte component.
The fix is on its way, please bear with me.

@DanielRios549 and @ninicdennis, would you mind trying version 1.0.1 please?

@feugy Version 1.0.1 fix the error for me. Thank you so much.

@feugy Verified on my end its working as intended! Thank you!