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

NX 15.8.5 debug error #15536

Closed
janosroska opened this issue Mar 8, 2023 · 8 comments
Closed

NX 15.8.5 debug error #15536

janosroska opened this issue Mar 8, 2023 · 8 comments
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: core core nx functionality type: bug

Comments

@janosroska
Copy link

Current Behavior

When trying to debug the application from VSCode, run-one.js throws an error.

Expected Behavior

The expected functionality would be to be able to debug the application without errors.

GitHub Repo

https://github.com/janosroska/latest

Steps to Reproduce

  1. create a new nestjs application with NX 15.8.5 or upgrade your repository from NX 13.10.2 to 15.8.5
  2. After creation/migration, try debugging the application
  3. observe the error in VSCode DEBUG CONSOLE

Nx Report

Node : 16.19.1
   OS   : win32 x64
   npm  : 8.19.3

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

Failure Logs

C:\Program Files\nodejs\npx.cmd nx serve myapp --inspect .\apps\myapp\src\main.ts
2
Debugger attached.
nx.js run [project][:target][:configuration] [_..]

Run a target for a project
    (e.g., nx run myapp:serve:production).

    You can also use the infix notation to run a target:
    (e.g., nx serve myapp --configuration=production)

    You can skip the use of Nx cache by using the --skip-nx-cache option.

Options:
      --version           Show version number  [boolean]
  -c, --configuration     This is the configuration to use when performing tasks on projects  [string]
      --output-style      Defines how Nx emits outputs tasks logs  [string] [choices: "dynamic", "static", "stream", "stream-without-prefixes", "compact"]
      --exclude           Exclude certain projects from being processed  [string] [default: ""]
      --parallel          Max number of parallel processes [default is 3]  [string]
      --runner            This is the name of the tasks runner configured in nx.json  [string]
      --verbose           Prints additional information about the commands (e.g., stack traces)  [boolean] [default: false]
      --nx-bail           Stop command execution after the first failed task  [boolean] [default: false]
      --nx-ignore-cycles  Ignore cycles in the task graph  [boolean] [default: false]
      --skip-nx-cache     Rerun the tasks even when the results are available in the cache  [boolean] [default: false]
      --project           Target project  [string]

TypeError: Cannot read properties of undefined (reading 'startsWith')
    at calculateDefaultProjectName (d:\NX_BUG_REPROD\latest\node_modules\nx\src\command-line\run-one.js:103:31)
    at parseRunOneOptions (d:\NX_BUG_REPROD\latest\node_modules\nx\src\command-line\run-one.js:58:32)
    at Object.<anonymous> (d:\NX_BUG_REPROD\latest\node_modules\nx\src\command-line\run-one.js:22:22)
    at Generator.next (<anonymous>)
    at fulfilled (d:\NX_BUG_REPROD\latest\node_modules\tslib\tslib.js:164:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2
Waiting for the debugger to disconnect...

Additional Information

The value of the cwd and root variables are different, root starts with a lowercase letter and the cwd with an uppercase. The first character is the drive letter, for ex. "d:\NX_BUG_REPROD\latest", "D:\NX_BUG_REPROD\latest"

The original (13.10.2) code checks whatever the relativeCwd variable is undefined or not. We did not invastigate any other places but probably there are more places where this problem exists in the new (15.8.5) version.

function calculateDefaultProjectName(cwd, root, projectsConfigurations, nxJsonConfiguration) {
var _a;
let relativeCwd = cwd.replace(/\/g, '/').split(root.replace(/\/g, '/'))[1];
relativeCwd = relativeCwd.startsWith('/')
? relativeCwd.substring(1)
: relativeCwd;

@natrixofficial
Copy link

natrixofficial commented Mar 8, 2023

On windows 10, x64. After migrating NX from 13 to latest (15.8.5), experiencing the same.
(Windows drive letter casing mismatch problems are annoying)
The solution was that we hade to downgrade and wait for a fix.

@robc123
Copy link

robc123 commented Mar 10, 2023

Not 100% sure if this is related, but it feels like it might be similar issue, so added here as comment rather than new issue.

Node : 16.19.0
   OS   : win32 x64
   npm  : 8.19.3

   nx                      : 15.8.5
   @nrwl/js                : 15.8.5
   @nrwl/jest              : 15.8.5
   @nrwl/linter            : 15.8.5
   @nrwl/workspace         : 15.8.5
   @nrwl/angular           : 15.8.5
   @nrwl/cli               : 15.8.5
   @nrwl/cypress           : 15.8.5
   @nrwl/devkit            : 15.8.5
   @nrwl/eslint-plugin-nx  : 15.8.5
   @nrwl/nest              : 15.8.5
   @nrwl/node              : 15.8.5
   @nrwl/tao               : 15.8.5
   @nrwl/webpack           : 15.8.5
   typescript              : 4.9.5

Community plugins:
@ngrx/effects : 15.3.0
@ngrx/entity : 15.3.0
@ngrx/router-store : 15.3.0
@ngrx/store : 15.3.0
@ngrx/eslint-plugin : 15.3.0
@ngrx/schematics : 15.3.0
@ngrx/store-devtools : 15.3.0
@twittwer/compodoc : 1.9.0

Node Breakpoint error

Can get debugger to attach to Node and debug console sees the api logger messages, but is failing to link breakpoints.
This works ok in NX 15.5.2

launch.json

  {
      "type": "node",
      "request": "attach",
      "name": "Attach to Api",
      "sourceMaps": true,
      "port": 9229,
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "${workspaceFolder}",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "outFiles": [
        "${workspaceFolder}/dist/apps/api/**/*.js"
      ]
    },

Debug Diagnostics help on "why my breakpoints don't bind":

✅ This breakpoint was initially set in:

C:\d_drive\github\tools-web\apps\api\src\setup\tag.service.ts line 58 column 1

❓ We couldn't find a corresponding source location, but found some other files with the same name:

c:\d_drive\github\tools-web\apps\api\src\setup\tag.service.ts
If this is the same file, you may need to adjust your build tool to correct the paths.

Chrome Launch Error

Similar to above but this may also be related to issues I've researched on Chrome version. t
It worked in NX15.5.2 until yesterday - it does not today (hence suspect chrome).
Saturday update: Chrome definitely needs a launch alteration to actually open - this now works on NX15.5.2 BUT breakpoints are still unlinked in NX15.5.2 as well - seems it does not completely resolve it - more Chrome research needed

launch.json

{
      "name": "Launch Chrome",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}/apps/frontend/src",
      "skipFiles": [
        "${workspaceFolder}/node_modules/**/*.js"
      ],
      "breakOnLoad": true,
      "sourceMapPathOverrides": {
        "webpack:///src/*": "${webRoot}/*"
      }
    },

In this case the launched browser opens but actually fails to load the angular application (maybe the unrelated chrome error). navigation manually to http://localhost:4200 is all fine.
Investigation of Debug Diagnostics has a similar path related warning:

C:\d_drive\github\tools-web\apps\frontend\src\app\projects+state\project.facade.ts line 1085 column 1

❓ We couldn't find a corresponding source location, and didn't find any source with the name project.facade.ts.

How did you expect this file to be loaded? (If you have a compilation step, you should pick 'sourcemap')
Loaded in directly Be parsed from a sourcemap
Here's some hints that might help you:
Make sure you have "sourceMap": true in your tsconfig to generate sourcemaps.
It looks like you narrowed the outFiles in your launch.json.
Try removing this: it now defaults to the whole workspace, and overspecifying it can unnecessarily narrow places where we'll resolve sourcemaps.

@AgentEnder AgentEnder added the scope: core core nx functionality label Mar 13, 2023
@janosroska
Copy link
Author

@AgentEnder I would like to raise the priority of the ticket, because besides debug, build and run are not working

d:\NX_BUG_REPROD\latest>npx nx build:all
nx.js run [project][:target][:configuration] [_..]

Run a target for a project
(e.g., nx run myapp:serve:production).

You can also use the infix notation to run a target:
(e.g., nx serve myapp --configuration=production)

You can skip the use of Nx cache by using the --skip-nx-cache option.

Options:
--version Show version number [boolean]
-c, --configuration This is the configuration to use when performing tasks on projects [string]
--output-style Defines how Nx emits outputs tasks logs [string] [choices: "dynamic", "static", "stream", "stream-without-prefixes", "compact"]
--exclude Exclude certain projects from being processed [string] [default: ""]
--parallel Max number of parallel processes [default is 3] [string]
--runner This is the name of the tasks runner configured in nx.json [string]
--verbose Prints additional information about the commands (e.g., stack traces) [boolean] [default: false]
--nx-bail Stop command execution after the first failed task [boolean] [default: false]
--nx-ignore-cycles Ignore cycles in the task graph [boolean] [default: false]
--skip-nx-cache Rerun the tasks even when the results are available in the cache [boolean] [default: false]
--project Target project [string]

Error: Both project and target have to be specified
at parseRunOneOptions (d:\NX_BUG_REPROD\latest\node_modules\nx\src\command-line\run-one.js:81:15)
at Object. (d:\NX_BUG_REPROD\latest\node_modules\nx\src\command-line\run-one.js:22:22)
at Generator.next ()
at fulfilled (d:\NX_BUG_REPROD\latest\node_modules\tslib\tslib.js:164:62)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

@AgentEnder
Copy link
Member

nx build:all isn't a valid command. If build:all is truly a target, you would need to run either nx build:all {projectName} or nx run {projectName}:build:all.

It seems more likely that you are wanting to run build on all projects, in which case the correct command is nx run-many -t build.

@AgentEnder
Copy link
Member

I believe this PR likely fixed the issue with casing that was noted: #15643

If so, this would be fixed in 15.8.7

@AgentEnder AgentEnder added the blocked: retry with latest Retry with latest release or head. label Mar 20, 2023
@natrixofficial
Copy link

Hi,

We have tried with the latest but still can't debug. We have read others' comments of other tickets, and found out how to debug:
#14708 (comment)

The problem was with the webpack config.

In one sentence: With the latest version (15.8.7) and with the modified webpack.config.js everything works on windows 10 and windows 11. Build, run, debug with WSCode...

@janosroska
Copy link
Author

Many thx @AgentEnder @natrixofficial

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: core core nx functionality type: bug
Projects
None yet
Development

No branches or pull requests

3 participants