nrwl / nx

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

After update to latest (`15.7.x`) debugger doesn't attach to breakpoints #15159

Open tonivj5 opened 1 year ago

tonivj5 commented 1 year ago

Current Behavior

I use Javascipt debug terminal functionality from vscode, it's similar to its auto-attach but on demands. After update to latest nx version, I can not debug my app in this way.

Expected Behavior

The debugger is attached to the process

GitHub Repo

https://github.com/tonivj5/nx-debug-bug

Steps to Reproduce

  1. git clone https://github.com/tonivj5/nx-debug-bug.git
  2. npm i
  3. put a breakpoint into any line of apps/test/src/main.ts
  4. open vscode, press Ctrl + p (or your shortcurts) and write >javascript debug terminal, enter image
  5. this open an auto-attachable terminal, launch the app: ./node_modules/.bin/nx serve test
  6. it works, awesome 🎉 image
  7. now, let's go to see the bug. Stop the debugger/process
  8. git checkout no-debug
  9. npm i
  10. launch the app: ./node_modules/.bin/nx serve test
  11. now the breakpoint doesn't work (unlinked breakpoint) 😢 Give it 2 - 3 tries image

Nx Report

- report from 15.2.1

 >  NX   Report complete - copy this into the issue template

   Node : 19.4.0
   OS   : linux x64
   npm  : 9.2.0

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

Done in 0.52s.
- report from 15.7.2
>  NX   Report complete - copy this into the issue template

   Node : 19.4.0
   OS   : linux x64
   npm  : 9.2.0

   nx                      : 15.7.2
   @nrwl/jest              : 15.7.2
   @nrwl/linter            : 15.7.2
   @nrwl/workspace         : 15.7.2
   @nrwl/cli               : 15.7.2
   @nrwl/devkit            : 15.7.2
   @nrwl/eslint-plugin-nx  : 15.7.2
   @nrwl/js                : 15.7.2
   @nrwl/nest              : 15.7.2
   @nrwl/node              : 15.7.2
   @nrwl/tao               : 15.7.2
   @nrwl/webpack           : 15.7.2
   typescript              : 4.8.4

Done in 0.69s.

Failure Logs

- Logs from 15.2.1

Debugger attached.

> nx run test:serve

Debugger attached.
Debugger attached.
Debugger attached.
chunk (runtime: main) main.js (main) 2.67 KiB [entry] [rendered]
webpack compiled successfully (4704159d10c4e0ee)
Type-checking in progress...
Debugger attached.
[Nest] 231210  - 02/21/2023, 9:13:47 PM     LOG [NestFactory] Starting Nest application...
[Nest] 231210  - 02/21/2023, 9:13:47 PM     LOG [InstanceLoader] AppModule dependencies initialized +22ms
[Nest] 231210  - 02/21/2023, 9:13:47 PM     LOG [RoutesResolver] AppController {/api}: +9ms
[Nest] 231210  - 02/21/2023, 9:13:47 PM     LOG [RouterExplorer] Mapped {/api, GET} route +2ms
[Nest] 231210  - 02/21/2023, 9:13:47 PM     LOG [NestApplication] Nest application successfully started +2ms
[Nest] 231210  - 02/21/2023, 9:13:47 PM     LOG 🚀 Application is running on: http://localhost:3333/api
No errors found.

- Logs from 15.7.2

Debugger attached.

> nx run test:serve

Debugger attached.
Debugger attached.
Debugger attached.
chunk (runtime: main) main.js (main) 2.67 KiB [entry] [rendered]
webpack compiled successfully (2f7d8650eed852b3)
Type-checking in progress...
No errors found.
Debugger attached.
[Nest] 230000  - 02/21/2023, 9:09:18 PM     LOG [NestFactory] Starting Nest application...
[Nest] 230000  - 02/21/2023, 9:09:19 PM     LOG [InstanceLoader] AppModule dependencies initialized +14ms
[Nest] 230000  - 02/21/2023, 9:09:19 PM     LOG [RoutesResolver] AppController {/api}: +6ms
[Nest] 230000  - 02/21/2023, 9:09:19 PM     LOG [RouterExplorer] Mapped {/api, GET} route +3ms
[Nest] 230000  - 02/21/2023, 9:09:19 PM     LOG [NestApplication] Nest application successfully started +2ms
[Nest] 230000  - 02/21/2023, 9:09:19 PM     LOG 🚀 Application is running on: http://localhost:3333/api

Additional Information

No response

tagplus5 commented 1 year ago

nx 15.6.3 debug don't works too I have tested couple nx versions and last version with working debug is 15.6.2

Dzixxx commented 1 year ago

+100, makes work significantly more annoying 😂

PS. Adding debugger at the beginning of your code makes functionality working again (bounds VS breakpoints which are after) but it's only a hotfix.

tagplus5 commented 1 year ago

@Dzixxx what executor do you use? If you create new project with nx 15.7.2 and add nest app, default executor will be @nrwl/js:node and you solution don't works.

 "serve": {
      "executor": "@nrwl/js:node",
      "options": {
        "buildTarget": "api:build"
      },
      "configurations": {
        "production": {
          "buildTarget": "api:build:production"
        }
      }
    },
Dzixxx commented 1 year ago

I'm using @nrwl/node:node but I also figured out that it works only if U will use at the beginning keyword debugger. After removing it it will work as long as U have it connected 😢

alljinx commented 1 year ago

+1 really a pain !

krzysztofKubiakVizlib commented 1 year ago

Experience of work with Node is terrible right now ;/

gdraganic commented 1 year ago

As a temporary workaround please try this: https://github.com/nrwl/nx/issues/14708#issuecomment-1457996600

slaby93 commented 1 year ago

Still a issue

driley-abbvie commented 1 year ago

+1 want this back

ziacik commented 1 year ago

This is becoming more and more frustrating. This tool should help save time, yet every single upgrade one has to spend hours and hours trying to work around basic things that stopped working. Are there no tests for this? Please fix.

tomachianura commented 1 year ago

any update on this? I've tested even the latest v15.9.2 of nx and @nrwl/nest but still doesn't work. This is very needed! Any timeframe for this to be fixed?

parzival418 commented 1 year ago

Also bumping up. This just stopped working for me one day, and it is very frustrating.

nftgeek commented 1 year ago

Really frustrating! still breakpoints are not attaching on "nx": "16.1.0",

lukepetrocochino commented 1 year ago

Still not working, so frustrating

alljinx commented 1 year ago

As a temporary workaround please try this: #14708 (comment)

You should definitly use this as a temporary workaround...

drackp2m commented 1 year ago

Currently using 16.3.2 and I still can't fix the breakpoints.

Other colleagues have already commented, but @gdraganic solution works perfectly.

goinnovise commented 1 year ago

I am curious if anyone has upgraded to 16.9.1 to see if breakpoints work?

The workaround works for me, but it does seem like it takes a bit longer to hot-reload after changes are made. Not sure if it's related to the work-around.

drackp2m commented 1 year ago

Indeed, I upgraded to nx 16.9.1, but also my docker image to node:20.7-alpine3.18, and I can confirm that everything works great without having to apply @gdraganic's solution.

In my case, I am not experiencing performance problems, indeed, possibly because I have upgraded my node version from 20.2 to 20.7, I have noticed that both the change detection and transpilation process is considerably faster.

github-actions[bot] commented 8 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! 🙏

tonivj5 commented 8 months ago

Up!

Brocco commented 7 months ago

Confirming the issue still remains as of version 18.3.2

Running a node CLI-based tool

berkoca commented 5 months ago

Is there any progress on this issue?

minikdev commented 5 months ago

bump. have the issue with version 19.0.6

anh-ocean commented 5 months ago

throw new Error(Could not find ${fileToRun}. Make sure your build succeeded.);

Brocco commented 3 months ago

Update - I updated my project to v19.6.1 and was able to successfully debug via vs code 🎉🎉🎉

My launch.json config looks like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node-terminal",
      "name": "Run npm script",
      "request": "launch",
      "command": "npm run { script name }",
      "cwd": "${workspaceFolder}"
    }
  ]
}
minikdev commented 2 months ago

I have 2 apps (node.js and nest.js) and run them by running nx run-many --target=serve --projects=api,transactions --parallel command. How can I add a debugger to both of them?

adamwdennis commented 2 months ago

see my comment here: https://github.com/nrwl/nx/issues/14708#issuecomment-2366954520