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

v 4.11.0 - Cannot read properties of undefined (reading 'INTAKE_SITE_US5') #1562

Closed
feedmypixel opened this issue May 23, 2022 · 12 comments
Closed

Comments

@feedmypixel
Copy link

feedmypixel commented May 23, 2022

Of Note

This appears to be different to #1547

  • Using @datadog/browser-rum: with "react": "18.1.0" and "react-dom": "18.1.0"
  • Using @datadog/browser-rum: 4.11.0 - errors
  • Using @datadog/browser-rum: 4.9.0 - works

Versions that work

The version our code last worked with is @datadog/browser-rum 4.9.0

Version that don't work

Using @datadog/browser-rum >= 4.10.0 we have the below problem

This issue is also present on:

  • @datadog/browser-rum 4.10.4
  • @datadog/browser-rum 4.11.0

Issue

When placing datadog.init within an if statement so it only runs in a particular environment (production):

import {datadogRum} from '@datadog/browser-rum';


  if (config.isProduction) {
      datadogRum.init({
...

And we run the code in the not allowed environment (not production), we get the error:

Uncaught TypeError: Cannot read properties of undefined (reading 'INTAKE_SITE_US5')

Note this works fine on v4.11.0 when it is in the allowed environment (production). But gives us the error when it is not in the allowed environment.

  • I have noticed if I comment out the datadogRum.init call that is inside the if that is not executed, then I do not get the error.
  • I have also sanity checked that the if condition is correct and the code does not enter the if statement, the datadogRum.init doesn't run when you are not in the allowed environment
  • It is almost as if the If statement is not being respected and the inclusion of datadogRum.init in the code, even though it is not being ran, is causing this error.
  • If I set up a vanilla React and Datadog example with v4.11.0 inside an if that is not executed, it runs without an error - https://stackblitz.com/edit/react-ts-luwuak?file=App.tsx
  • But in our apps code (sorry I can't share the code) if I only change "@datadog/browser-rum" from "4.9.0" to 4.11.0 it gives us the Uncaught TypeError: Cannot read properties of undefined (reading 'INTAKE_SITE_US5') error in environments where the code inside the if statement is not executed
  • Because of the previous point this feels like the package change of "@datadog/browser-rum" is causing this issue but only in our setup. I'm struggling to see what else is causing this or what is missing between v4.9.0 and v4.11.0
  • The code with v4.11.0 runs fine in the "allowed" environment (production)
  • Is this potentially a Webpack circular dependency bug?
  • Very weird issue so it feels like there is something going on that I am unaware of

Fix

My current fix is to lock @datadog/browser-rum: to v4.9.0, this works in all environments, but is not ideal

Please let me know if you need anything else that could be of help?

@bcaudan
Copy link
Contributor

bcaudan commented May 24, 2022

Hello @feedmypixel,

So If I understand correctly, you can't reproduce the issue outside of your setup?
Are you also using react-scripts-ts in your setup or a different build system?

Given the fix that we did for #1547, still having a dependency loop here seems quite odd to me 🤔
Sanity check, have you ensured that you still encounter this issue with a fresh setup? In case it could be related to leftovers in node modules or build artifacts.

@feedmypixel
Copy link
Author

feedmypixel commented May 24, 2022

So If I understand correctly, you can't reproduce the issue outside of your setup?

correct

Are you also using react-scripts-ts in your setup or a different build system?

A custom company build system

Sanity check, have you ensured that you still encounter this issue with a fresh setup? In case it could be related to leftovers in node modules or build artifacts.

Yeah it feels like a really weird bug. I have removed node_modules and build artifacts. Will sanity check all this today and get back

@feedmypixel
Copy link
Author

Ok so sanity checked this. The bug is as originally described. The error I am getting in my console after removing node_modules and the build artifacts, using version @datadog/browser-rum: v4.11.0 is:

parts of the bundle names have been redacted

vendors-node_modules-7d982d.dd7d9fb6.bundle.js:13272 Uncaught TypeError: Cannot read properties of undefined (reading 'INTAKE_SITE_US5')
    at Module.INTAKE_SITE_US5 (vendors-node_modules-7d982d.dd7d9fb6.bundle.js:13272:125)
    at Module../node_modules/@datadog/browser-core/esm/domain/internalMonitoring/internalMonitoring.js (internalMonitoring.tss:52:1)
    at __webpack_require__ (bootstrapp:19:1)
    at Module../node_modules/@datadog/browser-core/esm/domain/internalMonitoring/index.js (vendors-node_modules-7d982d.dd7d9fb6.bundle.js:13568:77)
    at __webpack_require__ (bootstrapp:19:1)
    at Module../node_modules/@datadog/browser-core/esm/domain/console/consoleObservable.js (vendors-node_modules-7d982d.dd7d9fb6.bundle.js:13436:77)
    at __webpack_require__ (bootstrapp:19:1)
    at Module../node_modules/@datadog/browser-core/esm/tools/display.js (vendors-node_modules-7d982d.dd7d9fb6.bundle.js:15036:91)
    at __webpack_require__ (bootstrapp:19:1)
    at Module../node_modules/@datadog/browser-core/esm/browser/cookie.js (vendors-node_modules-7d982d.dd7d9fb6.bundle.js:12793:72)

@bcaudan
Copy link
Contributor

bcaudan commented May 24, 2022

OK, we are currently removing all the dependency cycles (cf #1559) and it should be done in the coming days.
We'll ping back here when it will be released.

@feedmypixel
Copy link
Author

OK, we are currently removing all the dependency cycles (cf #1559) and it should be done in the coming days.
We'll ping back here when it will be released.

@bcaudan Many thanks

@luisabtrace
Copy link

Just to let you know, I'm experiencing the same issue. However, for me, it starts to fail at 4.10.1. In particular, 4.10.0 still works. 4.11.1 also fails, fyi.

@BenoitZugmeyer
Copy link
Member

Just to keep you updated, the last circular dependencies have been removed with #1567 . We'll release a new version on Monday if everything's right.

@feedmypixel
Copy link
Author

@BenoitZugmeyer thanks for the update. I'll report back once you have released and we have upgraded the package and tested

@BenoitZugmeyer
Copy link
Member

A new version have been released, but I still spoted some circular depencies! Your issue might be solved without waiting for the last circular dependencies to be fixed though. Let me know.

@feedmypixel
Copy link
Author

Thanks @BenoitZugmeyer I can't get to this until next week. But will update and report back and close this issue if all is resolved

@BenoitZugmeyer
Copy link
Member

The last circular dependencies are fixed with v4.11.3. Feel free to reopen if you still experience the issue.

@feedmypixel
Copy link
Author

I can confirm https://github.com/DataDog/browser-sdk/releases/tag/v4.11.5 works for us - thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants