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

npm task detection finds nothing in multi-root workspace #57897

Closed
mgabeler-lee-6rs opened this issue Sep 4, 2018 · 8 comments
Closed

npm task detection finds nothing in multi-root workspace #57897

mgabeler-lee-6rs opened this issue Sep 4, 2018 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@mgabeler-lee-6rs
Copy link

Issue Type: Bug

  1. Open one npm project in a workspace, observe that npm tasks are detected
  2. Add a second npm project to the workspace, observe that no npm tasks are detected at all

Note: tried downgrading to 1.26.0, same problem there. I suspect this is a compatibility issue with some system/environmental update, as it broke for me on ~ Aug 30th. I had installed 1.26.1 on Aug 17th, and this was not broken initially then.

I've tried launching with all extensions disabled and the problem persists.

VS Code version: Code 1.26.1 (493869e, 2018-08-16T18:34:20.517Z)
OS version: Linux x64 4.9.0-8-amd64

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 x 3208)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
video_decode: unavailable_software
video_encode: unavailable_software
webgl: enabled
webgl2: enabled
Load (avg) 2, 1, 1
Memory (System) 15.55GB (3.38GB free)
Process Argv /usr/share/code/code --unity-launch
Screen Reader no
VM 0%
Extensions (13)
Extension Author (truncated) Version
ng-template Ang 0.1.10
markdown-preview-github-styles bie 0.1.3
vscode-markdownlint Dav 0.20.0
vscode-eslint dba 1.5.0
EditorConfig Edi 0.12.4
tslint eg2 1.0.38
vscode-npm-script eg2 0.3.5
prettier-vscode esb 1.6.1
beautify Hoo 1.4.2
debugger-for-chrome msj 4.9.0
vscode-docker Pet 0.1.0
html-preview-vscode tht 0.1.1
reflow-paragraph Tro 1.3.0

(1 theme extensions excluded)

@mgabeler-lee-6rs
Copy link
Author

Also possibly of note:

The Tasks output console reports Error: script.match is not a function, and then Error: The npm task detection didn't contribute a task for the following configuration: for each npm task configured in each project's .vscode/tasks.json -- all of which are Tasks 2.0.0.

@dbaeumer dbaeumer assigned egamma and unassigned dbaeumer Sep 10, 2018
@egamma egamma added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster and removed bug Issue identified by VS Code Team member as probable bug labels Sep 11, 2018
@egamma
Copy link
Member

egamma commented Sep 14, 2018

@mgabeler-lee-6rs I cannot reproduce this problem. I´ve tried the setup below. I´ve created it as follows:

  • File>Open folder -> project1
  • File>Add Folder to Workspace -> project2

Both projects contain a tasks.json file. As you can see below the tasks are properly detected.

image

@mgabeler-lee-6rs
Copy link
Author

Here's a minimal test procedure that repro's the issue for me:

  1. mkdir tmp1
  2. cd tmp1
  3. npm init -- accept all defaults, creates a minimal package.json with a placeholder test script
  4. cd ..
  5. Repeat above but using tmp2 for the package
  6. From a fresh empty workspace in vscode, add tmp1 -- its test script shows in the 'NPM SCRIPTS' panel
  7. Add tmp2 to the workspace -- only tmp1 shows in the detected npm scripts
  8. Remove tmp1 from the workspace -- npm scripts is now empty
  9. Remove tmp2 from workspace -- npm scripts is of course empty
  10. Add tmp2 back to the workspace -- npm scripts still empty
  11. Add tmp1 back to the workspace -- npm scripts still empty

Screenshot of final state:
image

Is there a way to get debug output out of the npm task detection? I rummaged through all the output windows and, unlike my real use case, don't even see the warning(?) messages I mentioned in the original post.

@egamma
Copy link
Member

egamma commented Sep 17, 2018

@mgabeler-lee-6rs thanks for the repro. There is a caching issue when a new root folder is added. The extension should also watch for workspace folder changes.

As a work around you can I reload the window, then all the tasks are detected, see below.

image

@mgabeler-lee-6rs
Copy link
Author

mgabeler-lee-6rs commented Sep 17, 2018

While the workaround addresses the repro case, it doesn't address my real case. Trying to find a better repro that matches my real case.

Edit: problem is something about a rush monorepo I have. Working on a minimal repro case for that.

@mgabeler-lee-6rs
Copy link
Author

I was able to bisect-ish my real repo and isolate it to a package.json from a dependency in my monorepo.

bunyan-prettystream as a weird / invalid scripts section in its package.json. Presence of this file in the node_modules / pnpm cache directories for the monorepo seems to break task detection entirely.

https://github.com/mrrama/node-bunyan-prettystream/blob/master/package.json#L26

  "scripts": {
    "test": "make test",
    "travis-cov": { "threshold": 70 }
  }

Minimal test case:

  1. mkdir tmp1 && cd tmp1 && npm init && cd - -- take defaults for npm
  2. mkdir -p tmp2/tmp3 && cd tmp2/tmp3
  3. npm init -- take defaults
  4. (still in tmp2/tmp3): Edit package.json, add:
  "dependencies": {
    "bunyan-prettystream": "0.1.3"
  }
  1. cd .. and edit rush.json:
{
  "rushVersion": "5.0.0",
  "pnpmVersion": "2.13.6",
  "projects": [
      {
          "packageName": "tmp3",
          "projectFolder": "tmp3"
      }
  ]
}
  1. (still in tmp2): rush update
  2. Add tmp2 and tmp3 to a workspace, reload the window as many times as you want, no npm tasks.
  3. Does show Error: script.match is not a function in the console

I'm guessing that it's assuming the value of each script key is going to be a string, and trying to call match on it to see if it looks like something ... scripty? But when the package has a bogus-ish script key whose value is an object, it breaks, and the thrown exception aborts task detection?

@egamma egamma closed this as completed in e93bb0c Sep 17, 2018
@egamma egamma reopened this Sep 17, 2018
@mgabeler-lee-6rs
Copy link
Author

mgabeler-lee-6rs commented Sep 17, 2018

Note: in addition to the "bad" package.json entry, it seems somehow related to the monorepo using pnpm instead of npm -- I tried just creating a simple package that installs the problem dependency via npm, and it didn't repro the error. Perhaps because the 'bad' package.json was inside a node_modules folder that vscode knew to ignore, but the pnpm cache dirs that rush sets up doesn't trigger vscode to ignore them?

In the pnpm-using monorepo, the problem package.json appears as: ./common/temp/pnpm-store/2/registry.npmjs.org/bunyan-prettystream/0.1.3/node_modules/bunyan-prettystream/package.json and ./common/temp/node_modules/.registry.npmjs.org/bunyan-prettystream/0.1.3/node_modules/bunyan-prettystream/package.json. It seems to be the former that triggers the problem.

@egamma egamma closed this as completed in 295f04a Sep 17, 2018
@egamma
Copy link
Member

egamma commented Sep 17, 2018

I could repro the issue with this minimal package.json

{
  "scripts": {
    "test": "echo test",
    "travis-cov": { "threshold": 70 }
  }
}

The code didn´t handle object valued scripts properly. It now skips over them since they cannot be run. The editor properly shows a warning in this case:
image

@egamma egamma added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Sep 18, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants