nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.52k stars 2.35k forks source link

repo with nestjs 9 and package manager pnpm has issues resolving rxjs #14061

Closed lwhiteley closed 1 year ago

lwhiteley commented 1 year ago

Current Behavior

Currently pnpm is resolving two different versions of rxjs in a repo with nestjs 9.

after install, the pnpm lock file will have similar content

  /rxjs/6.6.7:
    resolution: {integrity: sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==}
    engines: {npm: '>=2.0.0'}
    dependencies:
      tslib: 1.14.1
    dev: true

  /rxjs/7.8.0:
    resolution: {integrity: sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==}
    dependencies:
      tslib: 2.4.1

I added a package nest-pino that uses specific rxjs 7 api and that's where the issue started to show up. There could be more areas where having two different major versions is a problem but its just the one i happened to run into

Expected Behavior

Nx should not be using a different major version of rxjs from nestjs ^9

Github Repo

https://github.com/lwhiteley/rxjs-repro.git

Steps to Reproduce

Please note that the error happens in the LogInterceptor for nestjs-pino

commenting this line, should allow the api to work but it is still required for the setup

see: https://github.com/lwhiteley/rxjs-repro/blob/main/apps/core-api/src/helpers/configureLogging.ts

Nx Report

Node : 18.7.0
   OS   : linux x64
   pnpm : 7.20.0

   nx : 15.4.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.4.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.2
   @nrwl/js : 15.4.2
   @nrwl/linter : 15.4.2
   @nrwl/nest : 15.4.2
   @nrwl/next : Not Found
   @nrwl/node : 15.4.2
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.4.2
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.4.2
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.4.2
   @nrwl/webpack : 15.4.2
   @nrwl/workspace : 15.4.2
   @nrwl/vite : 15.4.2
   typescript : 4.9.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

   ------------------------------------------
   Dependencies worth noting:
   ------------------------------------------
    "nestjs-pino": "^3.1.1",
    "pino-http": "^8.3.0",
    "pino-pretty": "^9.1.1",
    "rxjs": "^7.8.0",

Failure Logs

[10:11:04.063] ERROR (758749):
    context: "ExceptionsHandler"
    message: "(0 , rxjs_1.catchError) is not a function"
    err: {
      "type": "Error",
      "message": "(0 , rxjs_1.catchError) is not a function",
      "stack":
          TypeError: (0 , rxjs_1.catchError) is not a function
              at LoggerErrorInterceptor.intercept (/home/dev/repo/node_modules/.pnpm/nestjs-pino@3.1.1_k7wt3lqunl6v7sj6psdgp67dpe/node_modules/nestjs-pino/LoggerErrorInterceptor.js:14:57)
              at /home/dev/repo/node_modules/.pnpm/@nestjs+core@9.2.1_e6la6qvsclaae2becwjnmfvsuq/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:23:36
              at InterceptorsConsumer.intercept (/home/dev/repo/node_modules/.pnpm/@nestjs+core@9.2.1_e6la6qvsclaae2becwjnmfvsuq/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:25:24)
              at /home/dev/repo/node_modules/.pnpm/@nestjs+core@9.2.1_e6la6qvsclaae2becwjnmfvsuq/node_modules/@nestjs/core/router/router-execution-context.js:46:60
              at /home/dev/repo/node_modules/.pnpm/@nestjs+core@9.2.1_e6la6qvsclaae2becwjnmfvsuq/node_modules/@nestjs/core/router/router-proxy.js:9:23
              at Layer.handle [as handle_request] (/home/dev/repo/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/layer.js:95:5)
              at next (/home/dev/repo/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:144:13)
              at Route.dispatch (/home/dev/repo/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:114:3)
              at Layer.handle [as handle_request] (/home/dev/repo/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/layer.js:95:5)
              at /home/dev/repo/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/index.js:284:15
    }

Additional Information

Notes:

Coly010 commented 1 year ago

Hey @lwhiteley

I cloned your repo, ran pnpm i, nx serve core-api and curl localhost:3333/health.

Everything seemed to work fine:

image

I also ran pnpm ls rxjs and got this:

image

Incase it is of any consequence, my pnpm version is 7.29.0

lwhiteley commented 1 year ago

@Coly010 awesome you are correct.. an updated version of pnpm resolves the issue.

tried with

pnpm: 7.30.5

you can handle closing the issue if there is nothing further to check

Thanks for checking!

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.