Importing module `@datadog/browser-logs` breaks on Google Cloud Platform
See original GitHub issueHi,
We’re experiencing an issue related to @datadog/browser-logs
crashing when running from a Google Cloud Platform environment due to the side-effects it performs when imported, namely the binding operations on console.{debug,log,info,warn,error}
executed at top-level from module display.ts.
This file contains top-level code assuming it runs in a browser and calls Function.bind
for all known logging methods of console
object. Such approach works fine in most web browser but breaks on our application hosted on Google Cloud Platform because the implementation of console
there doesn’t have a console.debug
function. I believe this regression was introduced with https://github.com/DataDog/browser-sdk/pull/1501 as only warn
, log
and error
were previously used and they all exist in GCP.
Current behavior may be intentional and rely on the fact @datadog/browser-logs
always runs within a standard web browser, which would be a fair assumption based on the package’s name. However since the package description says it is intended to “send logs to Datadog from web browsers or other Javascript clients”, you may also want to consider improving compatibility by checking the existence of console.debug
(and other functions) before trying to bind them.
Please let me know what makes most sense to you 🙂
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
Thanks for your feedback, we will update the README.md 🙂
OK then I think I was confused by the part in your README file that mentions “other Javascript clients”. Using the same library for browers and Node.js allowed us easier factorization, but I understand this may not be aligned with the intended usage of this package so we’ll split the codebase on our end. Thanks for your answer 🙂
(I would also recommand updating README.md to avoid any confusion 🙂)