Skip to content

fix(replay): Better guard for logger.info #8873

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

Closed
wants to merge 3 commits into from
Closed

Conversation

mydea
Copy link
Member

@mydea mydea commented Aug 28, 2023

Not sure if/why this should be required, but better safe then sorry I guess...

Hopefully fixes #8741

Not sure if/why this should be required, but better safe then sorry I guess... 

Hopefully fixes #8741
@mydea mydea requested review from billyvg, lforst and Lms24 August 28, 2023 07:50
@mydea mydea self-assigned this Aug 28, 2023
Copy link
Contributor

@lforst lforst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't go through with this change. There is no way this is doing anything except bloating unless there is something really really funky going on.

I'd rather look into situations where logger may be undefined. (i.e. accessing it without having the utils package loaded for some reason)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure how this can happen but perhaps info was tree-shaken out for some reason? This guard might work as long as __SENTRY_DEBUG__ isn't replaced by users.

Otherwise wdyt about checking for typeof logger.info === 'function'?

@mydea
Copy link
Member Author

mydea commented Aug 28, 2023

Honestly I am also not clear why/how this is happened, but it def. started happening once we replaced

__DEBUG_BUILD__ && logger.info()`
// became
if(!__DEBUG_BUILD__) {
  return;
}

logger.info()

To me it appears that this should be the same thing, but 🤷 .

To be clear this is happening for us on sentry.io as well: https://sentry.sentry.io/issues/4387494961/?project=11276&referrer=github_integration so it cannot be related to a build issue. I strongly suspect it is related to some browser extension stuff or similar, but it's hard to say. As it happens for users too, we should somehow guard against this. Feels hacky, but 🤷

But yeah, maybe it is cleaner to do typeof logger.info === 'function instead - actually will not be more verbose because __DEBUG_BUILD__ is replaced with some other code as well.

@lforst
Copy link
Contributor

lforst commented Aug 28, 2023

My suspicion is that this is happening with multiple sentry instances on the same page. (browser extensions)

@mydea
Copy link
Member Author

mydea commented Aug 28, 2023

OK, I rewrote this to use logger.log instead of logger.info. Maybe logger.info is somewhere (?) overwritten - we use this very little in the codebase. Let's see if that "fixes" it.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 75.19 KB (-0.01% 🔽)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.17 KB (0%)
@sentry/browser - Webpack (gzipped) 21.85 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 69.72 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 28.18 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 20.18 KB (-0.01% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 219.95 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 84.78 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 59.86 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.04 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 75.21 KB (-0.01% 🔽)
@sentry/react - Webpack (gzipped) 21.88 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 93.01 KB (-0.02% 🔽)
@sentry/nextjs Client - Webpack (gzipped) 50.7 KB (0%)

Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be helpful to log what info is when it is not a function

@mydea
Copy link
Member Author

mydea commented Aug 30, 2023

Closing in favor of #8880, which maybe/hopefully also fixes this.

@mydea mydea closed this Aug 30, 2023
@mydea mydea deleted the fn/guard-logger-info branch August 30, 2023 05:50
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

Successfully merging this pull request may close these issues.

Error in replay logging: TypeError: F.kg.info is not a function
4 participants