v 4.11.0 - Cannot read properties of undefined (reading 'INTAKE_SITE_US5')
See original GitHub issueOf Note
This appears to be different to https://github.com/DataDog/browser-sdk/issues/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"
to4.11.0
it gives us theUncaught 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 betweenv4.9.0
andv4.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?
Issue Analytics
- State:
- Created a year ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
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.
Just to keep you updated, the last circular dependencies have been removed with https://github.com/DataDog/browser-sdk/pull/1567 . We’ll release a new version on Monday if everything’s right.