in @google-cloud/opentelemetry-resource-util opentelemetry/api is declared as development only dependency, but is actually used in "production".
ervin-pactum opened this issue · 0 comments
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
N/A
What version of Node are you using?
N/A, yarn berry in pnp mode
What did you do?
If possible, provide a recipe for reproducing the error.
I am using modern yarn PNP mode, which ensures that packages only can see dependencies they declare, this leads to code depending on @google-cloud/opentelemetry-resource-util being non-deployable unless package is patched to add missing dependency.
What did you expect to see?
application startup, package usable.
What did you see instead?
' ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided module can't be loaded.
' Is there a syntax error in your code?
' Detailed stack trace: Error: @google-cloud/opentelemetry-resource-util tried to access @opentelemetry/api, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
' Required package: @opentelemetry/api
' Required by: @google-cloud/opentelemetry-resource-util@virtual:eecbd1d0b350489fd8e261420b70a0cc0e338d62ee9794a1ab8cd61f7a8ea4723444d65439bea19a80da7175c4eee58bf7a4032bda1a0a3d1faafd08709adedb#npm:2.2.0 (via /workspace/.yarn/__virtual__/@google-cloud-opentelemetry-resource-util-virtual-0d7cba935b/0/cache/@google-cloud-opentelemetry-resource-util-npm-2.2.0-56dcb4a1b6-f771ebeda0.zip/node_modules/@google-cloud/opentelemetry-resource-util/build/src/detector/)
' Require stack:
' - /workspace/.yarn/__virtual__/@google-cloud-opentelemetry-resource-util-virtual-0d7cba935b/0/cache/@google-cloud-opentelemetry-resource-util-npm-2.2.0-56dcb4a1b6-f771ebeda0.zip/node_modules/@google-cloud/opentelemetry-resource-util/build/src/detector/gce.js
Additional context
Add any other context about the problem here.
root cause: package opentelemetry-resource-util declares "@opentelemetry/api"
as devDependencies, but in reality uses it in production inside detector/gce.ts
For others who may be affected, there is workaround, (but it has to be performed in every workspace that uses @google-cloud/opentelemetry-resource-util so is not very scalable), add following to your .yarnrc.yml
:
packageExtensions: {
# TODO: FIXME: https://github.com/GoogleCloudPlatform/opentelemetry-operations-js/issues/729
"@google-cloud/opentelemetry-resource-util@*": {
dependencies: {
"@opentelemetry/api": "*",
},
}
}