-
Notifications
You must be signed in to change notification settings - Fork 137
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
Warnings on import: "SDK is loaded more than once. This is unsupported and might have unexpected behavior" #2919
Comments
This is expected, only one instance of the Logs SDK should be loaded at a time. Beside using a global variable (which doesn't cause any issue if you don't use it), the Logs SDK is also ding a few things globally:
That being said, this is not the first time we've had that request, and we probably should do something about it. In the meantime, you could ignore the warning. |
@BenoitZugmeyer I thought I'd add more context here. We load Aside from manually adding the package to the global scope myself - which seems like 'doubling up' if the package itself adds to the global scope, I'm not sure how it is intended to be used in a JS module-based app without getting these warnings. I'd like to request you reopen this and bump it's prio, as we're getting hundreds (maybe thousands) of errors in our test runs & build pipelines which are nearly impossible to ignore. |
Importing the library multiple times shouldn't be an issue. It should not evaluate the library multiple times, in the same way React isn't re-evaluated every time you `import React from 'react'. If it is an issue for you, you might have a problem in your bundler setup and somehow the SDK is included multiple times in your JS assets. This is highly ineficient, and I'd suggest adjusting your configuration. |
Seeing the same issue in our tests as well bumping from 5.8.0 to 5.26.0 version. Fixed tests by mocking the lib:
|
@BenoitZugmeyer sorry, I should have clarified, it just meant our test logs went crazy with the same error. There was no functional impact. @vytautas-vitkus-tg - I could kiss you! |
Steps to Reproduce
DatadogLogs
in both the webpage and the Chrome extension's content script.On import, the Datadog SDK calls
defineGlobal
on thewindow
object and produces the warning: "SDK is loaded more than once. This is unsupported and might have unexpected behavior."Environment
Additional Context
This issue occurs because my Chrome extension and the webpage share the same
window
object, resulting in two Datadog loggers being defined on the samewindow
.The text was updated successfully, but these errors were encountered: