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

Cannot read properties of undefined (reading 'startTime') #41066

Closed
qLutCh55 opened this issue Nov 7, 2022 · 5 comments
Closed

Cannot read properties of undefined (reading 'startTime') #41066

qLutCh55 opened this issue Nov 7, 2022 · 5 comments
Assignees

Comments

@qLutCh55
Copy link

qLutCh55 commented Nov 7, 2022

Environment

SaaS (https://sentry.io/)

Version

NA

Steps to Reproduce

So I installed sentry.io on my application - I started getting this error "Cannot read properties of undefined (reading 'startTime')" however nowhere in my codebase do I use the word "startTime".

Examined my app.js to see that it is something coming from sentry.io code.

App.js

let n,r=0,a=[];const o=t=>{t.forEach((t=>{if(!t.hadRecentInput){const e=a[0],o=a[a.length-1];r&&t.startTime-o.startTime<1e3&&t.startTime-e.startTime<5e3?(r+=t.value,a.push(t)):(r=t.value,a=[t]),r>i.value&&(i.value=r,i.entries=a,n&&n())}}))},s=be("layout-shift",o);s&&(n=he(t,i,e.reportAllChanges),xe((()=>{o(s.takeRecords()),n(!0)})))})((t=>{const e=t.entries.pop();e&&(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&a.kg.log("[Measurements] Adding CLS")

The related node_module file - node_modules/@sentry/tracing/esm/browser/web-vitals/getCLS.js - somewhere between line 50 and 71.

`// const handleEntries = (entries: Metric['entries']) => {
const handleEntries = (entries) => {
entries.forEach(entry => {
// Only count layout shifts without recent user input.
if (!entry.hadRecentInput) {
const firstSessionEntry = sessionEntries[0];
const lastSessionEntry = sessionEntries[sessionEntries.length - 1];

    // If the entry occurred less than 1 second after the previous entry and
    // less than 5 seconds after the first entry in the session, include the
    // entry in the current session. Otherwise, start a new session.
    if (
      sessionValue &&
      entry.startTime - lastSessionEntry.startTime < 1000 &&
      entry.startTime - firstSessionEntry.startTime < 5000
    ) {
      sessionValue += entry.value;
      sessionEntries.push(entry);
    } else {
      sessionValue = entry.value;
      sessionEntries = [entry];
    }`

Seems to call the property startTime of lastSessionEntry - which might not be available. Unfortunely I cannot provide the issue share link from sentry.io, as it contains sensitive information as user ip, etc.

Expected Result

No console or tracking error from importing sentry into application.

Actual Result

Get error - Cannot read properties of undefined (reading 'startTime')

@slavaboiko
Copy link

I am actually noticing the same issue

@masinette
Copy link
Member

masinette commented Nov 8, 2022

Hello there, @qLutCh55 . What is the version of your SDK? Is it related to this issue: getsentry/sentry-javascript#6083?

@getsentry-release
Copy link

Routing to @getsentry/support for triage. ⏲️

@qLutCh55
Copy link
Author

qLutCh55 commented Nov 8, 2022

@masinette Yeah seems to be the same issue. With the team already pushing a fix. Thanks

@MooseSaeed
Copy link

Same issue here

@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants