nrwl / nx

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

Nestjs-cls is invalid in the Nest App of nx [twists and turns] #19842

Closed sailengsi closed 4 months ago

sailengsi commented 11 months ago

Current Behavior

  1. I have a project based on nx-v16.x that has been developed for a long time;

  2. Previously, Nestjs-cls was introduced and everything was functioning normally;

  3. When I added the Nest app to the project, the same reusable code, Nestjs-cls, became invalid. Even copying the previous project from the apps was invalid. As of now, the dependency removal and reinstallation, which used to work well, are no longer effective;

  4. In order to ensure that it is my project issue, Nestjs-cls issue, or nx issue, I created two warehouses respectively. One is a pure project generated based on NesCli, and the other is a project based on the current nx-v17-- preset=nest. They only introduced Nestjs-cls, and ultimately found that NestCli's is OK, while nx's is still invalid;

Expected Behavior

I hope Nestjs-cls can be used normally in Nest of nx

GitHub Repo

No response

Steps to Reproduce

  1. https://github.com/sailengsi/nest-cls_ok ● Project based on nest-cli

  2. https://github.com/sailengsi/nx-nest-cls_bug ● Next project based on nx;

Both of the above two projects were exclusively, and only nestjs-cls were introduced in app.module.ts, and getId using ClsService in app.controller.ts was deleted by Console, since the input of nx projects was always undefined.

Nx Report

No abnormal output

Failure Logs

No response

Package Manager Version

pnpm 8.5.1

Operating System

Additional Information

No response

Papooch commented 11 months ago

This is ultimately a problem with NestJS itself, see mentioned issue and this NestJS issue.

sailengsi commented 11 months ago

This is ultimately a problem with NestJS itself, see mentioned issue and this NestJS issue.

Thank you, thank you very much for your answer. I can finally let go of my heart that has been hanging in suspense for the past two days.

sailengsi commented 11 months ago

It is found in the above clues that it has been solved in nestjs. Is that a bug in nx?

Papooch commented 11 months ago

It is not a bug in NX, but in NestJS. You did not encounter it, because you did not use global prefix withou NX. If you did, you would find the same issue.

sailengsi commented 11 months ago

It is not a bug in NX, but in NestJS. You did not encounter it, because you did not use global prefix withou NX. If you did, you would find the same issue.

Oh, yes, I forgot. In my actual project, I set GlobalPrefix, but it was not set in the demo I provided. Okay, thank you for your reminder

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 3 months 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.