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

in @google-cloud/opentelemetry-resource-util opentelemetry/api is declared as development only dependency, but is actually used in "production". #729

Open
ervin-pactum opened this issue Jul 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working priority: p3

Comments

@ervin-pactum
Copy link

ervin-pactum commented Jul 2, 2024

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": "*",
    },
  }
}
@ervin-pactum ervin-pactum added the bug Something isn't working label Jul 2, 2024
@aabmass aabmass self-assigned this Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: p3
Projects
None yet
Development

No branches or pull requests

2 participants