jufab / opentelemetry-angular-interceptor

An Angular Module for easely deploying OpenTelemetry
Apache License 2.0
37 stars 23 forks source link

Broken dependency in angular 16 for zone.js #166

Open andrs-o opened 1 year ago

andrs-o commented 1 year ago

Hi

I get an error when using the package for angular 16. Reproduce it by having angular 16 installed and: ng new check-opentelemetry-dependencies npm i @jufab/opentelemetry-angular-interceptor

Then I get the forllowing error (It seems like there is an dependency for zone.js): npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: undefined@undefined npm ERR! Found: zone.js@0.13.0 npm ERR! node_modules/zone.js npm ERR! peer zone.js@"~0.13.0" from @angular/core@16.0.4 npm ERR! node_modules/@angular/core npm ERR! peer @angular/core@">=13.0.0" from @jufab/opentelemetry-angular-interceptor@1.4.1-2 npm ERR! node_modules/@jufab/opentelemetry-angular-interceptor npm ERR! @jufab/opentelemetry-angular-interceptor@"" from the root project npm ERR! peer @angular/core@"16.0.4" from @angular/common@16.0.4 npm ERR! node_modules/@angular/common npm ERR! peer @angular/common@">=13.0.0" from @jufab/opentelemetry-angular-interceptor@1.4.1-2 npm ERR! node_modules/@jufab/opentelemetry-angular-interceptor npm ERR! @jufab/opentelemetry-angular-interceptor@"" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer zone.js@"^0.10.2 || ^0.11.0" from @opentelemetry/context-zone-peer-dep@1.13.0 npm ERR! node_modules/@opentelemetry/context-zone-peer-dep npm ERR! peer @opentelemetry/context-zone-peer-dep@"1.13.0" from @jufab/opentelemetry-angular-interceptor@1.4.1-2 npm ERR! node_modules/@jufab/opentelemetry-angular-interceptor npm ERR! @jufab/opentelemetry-angular-interceptor@"*" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

jufab commented 1 year ago

Hi @andrs-o ,

This is a peerDependencies rule in @opentelemetry/context-zone-peer-dep

"zone.js": "^0.10.2 || ^0.11.0"

https://github.com/open-telemetry/opentelemetry-js/blob/93285585ce816a30df8db2b4bdd6d39fd78da806/packages/opentelemetry-context-zone-peer-dep/package.json#L85

You can install and use it with a npm i @jufab/opentelemetry-angular-interceptor --force (I try the lib on angular 16 without problem)

valiant-code commented 1 year ago

I really hate to use --force or --legacy-peer-deps in my installs, it hides real issues. Would it make more sense to switch it to the bundled zone, @opentelemetry/context-zone? (or could it be possible to remove the need for it altogether..?) Since Angular requires version ^0.13 using the context-zone-peer-dep is just incompatible with Angular 16.

patricio-hondagneu-simplisafe commented 1 year ago

@jufab is right, we're facing the same issue with our project.

This is an upstream problem with @opentelemetry/context-zone-peer-dep@latest which depends on zone.js@"^0.11.0", while @angular/core@latest depends on zone.js@"~0.13.0".

Versions ^0.11.0 and ~0.13.0 are incompatible because of how Semantic Versioning makes an exception for packages with major version zero (0.x.x).

I'm not sure why, but this behavior changed for NPM between versions 8.5.5 (where installation succeeds) and 8.6.0 (where it starts failing). NPM was not correctly applying Semantic Versioning v2 before version 8.6.0, as it appears.

This is not going to be fixed by replacing @opentelemetry/context-zone-peer-dep@latest with @opentelemetry/context-zone@latest because, at the time of this comment, it also depends on zone.js@"^0.11.0" (you can see it here)

dovahkiin919 commented 1 year ago

Hello. Is there any update or an expected timeline on fix for broken dependency in Angular 16 for zone.js ? Thanks.

jufab commented 10 months ago

Next release on @opentelemetry/context-zone-peer-dep https://github.com/open-telemetry/opentelemetry-js/issues/4245

vincenzobadalamenti commented 8 months ago

Hi @jufab can you give us any news? We need the update of the peerDependencies . Thanks in advance

jufab commented 8 months ago

Hi @vincenzobadalamenti it's done since release 1.7.0 But I haven't tested it yet...

jufab commented 8 months ago

I tried with Angular 16, zone.js 0.13.3 and the new release 1.8.0. I don't have any problem. Can you confirm that's OK for you in order to close this issue, please? @andrs-o or someone else? thx