Skip to content

Use package.json location to determine the default program root #326

Closed

Description

I get bugs when using request: "pwa-node" but everything works ok when i use "debug.node.useV3": true in the settings.
Whats the difference, i thought both are using the new debugger?

Thanks

Activity

  1. connor4312 commented on Feb 11, 2020

    @connor4312
    Member

    That's interesting--usually we've seen the opposite 🙂

    The process for launching a debug session is roughly:

    1. Hit "start session"
    2. VS Code asks the debug extension registered for the type to fill in the config--resolving defaults and such
    3. VS Code takes the resolved config and starts a session

    The existing debuggers are still registered for types like node and chrome. The useV3tells tells them that at step 2, instead of returning a config with the same debug type, return a config with the pwa- prefix to point to the new debugger. Step 2 doesn't happen again, so this means that defaults get filled in by the old debuggers instead of the logic in js-debug.

    This has been the sources of a handful of bugs where we were expecting some new behavior that the old debugger didn't implement, or a new option that we didn't get a default for in step 3. But this is the first issue I've heard of pwa- failing and the non-prefixed one working! Can you describe the bugs are you running into?

  2. jasonwilliams commented on Feb 11, 2020

    @jasonwilliams
    ContributorAuthor

    ts-jest issue, Im running a test and setting a breakpoint.
    When i use pwa-node it completely crashes (like, i have to restart VSCode).
    But using the useV3 works ok.

    Im on VSCode Version: 1.42.0 Stable

        {
          "name": "(UI) Launch Debug Jest Tests",
          "type": "node",
          "request": "launch",
          "cwd": "${workspaceFolder}/ui",
          "runtimeArgs": ["./node_modules/.bin/jest"]
        }
    

    Output

    Note: Using the "preview" debug extension
    Verbose logs are written to:
    /Users/[User]/Library/Application Support/Code/logs/20200211T172326/exthost1/ms-vscode.js-debug-nightly/vscode-debugadapter-0.json
    /usr/local/bin/node ./node_modules/.bin/jest
    Debugger listening on ws://127.0.0.1:65439/50bb7dcc-feb5-4a18-a800-fddfaf3dec4e
    For help, see: https://nodejs.org/en/docs/inspector
    Debugger attached.
    
  3. jasonwilliams commented on Feb 11, 2020

    @jasonwilliams
    ContributorAuthor

    Both versions "Creating source from url" for every single node module, is there a way to skip anything inside of "node_modules" ?

  4. connor4312 commented on Feb 11, 2020

    @connor4312
    Member

    Thanks for the logs, I see some of why it's stopping in the code you've shared: it's a "pause" for us to parse a sourcemap, at which point the debugger just stops and doesn't continue. Are you able to share a link to the project you're working on so I can narrow down why it's not resuming? If not I can probably manage to get a reproduction, but it would make things easier :)

    Both versions "Creating source from url" for every single node module, is there a way to skip anything inside of "node_modules" ?

    Unfortunately not. Those sources are shown in the "Loaded Scripts" view on the side, and is information to create a stacktrace when paused, for example.

  5. added
    bug
    info-needed
    on Feb 11, 2020
  6. jasonwilliams commented on Feb 12, 2020

    @jasonwilliams
    ContributorAuthor

    Unfortunately the problem doesn't happen when i break it out into a test case.

    Edit: Now i know why, for some reason when i run it in the monorepo it starts parsing JS files from other folders within the larger project (i don't know why it's doing this), but when i extract just that folder out it works. I get a lot of no sourceRoot specified, using script dirname

    Yeah this is weird, for no rhyme or reason its parsing source maps from other projects, i never reference these files anywhere.

    Basically i get a load of

    {"tag":"sourcemap.parsing","timestamp":1581510743199,"message":"no sourceRoot specified, using script dirname","metadata":{"absSourceRoot":"/Users/[User]/workspace/monorepo/DifferentProject/vendor/@dep/core/_bundles"},"level":0}
    

    Ive noticed it only does it for folders that have .maps in them

    Also... looking through the trace there are some internal files which won't exist, for e.g

    {"tag":"runtime.sourcecreate","timestamp":1581507804406,"message":"Creating source from url","metadata":{"inputUrl":"internal/timers.js","absolutePath":"/Users/[User]/workspace/project/ui/internal/timers.js"},"level":0}

    Should they be added to SkipFiles?

  7. connor4312 commented on Feb 12, 2020

    @connor4312
    Member

    Hmm, the search paths for source maps is determined by the outFiles, which defaults to all JS files in your project excluding node_modules:

    "outFiles": [
      "/Users/[User]/workspace/project/**/*.js",
      "!**/node_modules/**"
    ],
    

    In the logs you sent it seems like this is working; I'm not seeing it parsing from a different folder and both the pwa-node and node logs contain about the same amount of sourcemap.parsing events.

    no sourceRoot specified, using script dirname is expected for TS files running in Node, that's mostly diagnostic.

  8. jasonwilliams commented on Feb 12, 2020

    @jasonwilliams
    ContributorAuthor

    Hmm, the search paths for source maps is determined by the outFiles, which defaults to all JS files in your project excluding node_modules:

    Thats interesting, I wasn't aware of that. So outFiles is using ${workspaceFolder} ?
    I work in a monorepo and i have the whole repo set as my workspace, (I'm sure others work in this way too). So i should probably scope that down to the folder i care about for this launch task.

    Is that a good default? I feel it's not obvious behaviour.

    Could there be some sort of root property it uses instead? or using tsconfig.json/package.json as the root?.
    I wouldn't know to set outFiles unless i have my sourcemaps in a very specific place, i wonder if there should be some documentation surrounding "outFiles" to explain this, at the very least the tooltip showing what the defaults are considering this is an easy trap to fall into if you use workspaces.

    I will try changing "outFiles" to the ui folder and see if that changes anything and come back to you.

  9. jasonwilliams commented on Feb 12, 2020

    @jasonwilliams
    ContributorAuthor

    Using "outFiles" fixes it, thanks.
    I still don't know why the old configuration worked fine though  😆

  10. connor4312 commented on Feb 12, 2020

    @connor4312
    Member

    I'm not sure either. In fact there's a log line in the pwa-node version saying that prediction successfully completed after 5.5 seconds. Maybe the log shared originally was the wrong one?

    {"tag":"perf.function","timestamp":1581444436585,"message":"","metadata":{"method":"BreakpointsPredictor.createInitialMapping","duration":5516},"level":0}
    

    I believe that outFiles defaulting to the entire workspace is a good default to most users. Alternatively, maybe it should default to the closest package.json relative to the debugged program? I believe Lerna et al. generally have package.json's in each submodule, so that could be a decent heuristic.

    cc roblourens

  11. jasonwilliams commented on Feb 12, 2020

    @jasonwilliams
    ContributorAuthor

    I believe that outFiles defaulting to the entire workspace is a good default to most users. Alternatively, maybe it should default to the closest package.json relative to the debugged program? I believe Lerna et al. generally have package.json's in each submodule, so that could be a decent heuristic.

    Yeah, i think that should be a fine heuristic to go by.
    Even if you decide not to do this, It's worth documenting the behaviour of "outFiles" anyway because i wouldn't have suspected it to work like that.

  12. removed
    info-needed
    on Feb 18, 2020
  13. changed the title [-]Whats the difference between "pwa-node" and "debug.node.useV3": true [/-] [+]Use package.json location to determine the default program root[/+] on Feb 18, 2020
  14. added 2 commits that reference this issue on Feb 18, 2020
    228e796
    9acc2e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions