denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97k stars 5.36k forks source link

Weird stop on inspector #7873

Closed Soremwar closed 3 years ago

Soremwar commented 4 years ago

When using the following launch configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Deno",
      "request": "launch",
      "type": "pwa-node",
      "program": "app.js",
      "cwd": "${workspaceFolder}",
      "runtimeExecutable": "deno",
      "runtimeArgs": [
        "run",
        "--inspect-brk",
        "--allow-read=./",
        "--allow-write=./storage",
        "--allow-net",
        "--unstable",
        "--importmap=libraries.json"
      ],
      "attachSimplePort": 9229
    }
  ]
}

On the following code: https://github.com/Soremwar/procalidad_app (checkout on branch dev)

I get a little error (stop?) telling me the following

Could not load source '/home/nicolas/Documents/Programming/procalidad_app/x/oak@v6.3.1/cookies.ts': Unable to retrieve source content.

image

Now I'm not sure if this has to do anything with Oak, some other content in my code, VSCode or Deno itself, but it's certainly odd and annoying at the time of debugging.

Versions

vscode: 1.49.3 deno: 1.4.4 extension: 2.3.1

Soremwar commented 4 years ago

UPDATE:

Found a minimal reproducible example:

import { Application } from "https://deno.land/x/oak@v6.3.1/mod.ts";

const app = new Application();

app.use((ctx) => {
  ctx.response.body = "Hello World!";
});

await app.listen({ port: 8000 });

Just put a breakpoint anywhere and watch it stop

ry commented 4 years ago

Good to have this reproduction. Thanks.

I wonder how we could ever test something like that? In order for this extension to be non-buggy in the future, we need to figure out a way to run tests like this.

lucacasonato commented 4 years ago

I doubt this is an extension issue. The extension doesn't actually implement the inspector protocol part. If any of that is broken it would be a VS Code issue.

More likely this is a future polling issue in Deno with inspector and main isolate. Is this reproducible in chrome dev tools?

Soremwar commented 4 years ago

Can reproduce in Chrome

Stops on some random oak code, there shouldn't be no reason for it

image

So perhaps this should be moved to denoland/deno ?

caspervonb commented 4 years ago

Found a minimal reproducible example:

Can't reproduce 🤔

Sniffing the websocket network log would help a-lot here, maybe try inspect the inspector for more details? (Open developer tools on the window that contains the devtools:// page that is connected to Deno).

KyleJune commented 4 years ago

Here is another reproduction path using deno test and no third party modules.

I'm using WSL for running deno, not sure if that is relevant to the issue. VS Code 1.50.0 deno 1.4.5 v8 8.7.220.3 typescript 4.0.3

example_test.ts

import { assert } from "https://deno.land/std@0.74.0/testing/asserts.ts";

Deno.test("example", () => {
  assert(true);
});

.vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "deno run",
      "type": "pwa-node",
      "outputCapture": "std",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "runtimeExecutable": "deno",
      "runtimeArgs": ["run", "--inspect-brk", "${file}"],
      "attachSimplePort": 9229
    },
    {
      "name": "deno test",
      "type": "pwa-node",
      "outputCapture": "std",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "runtimeExecutable": "deno",
      "runtimeArgs": ["test", "--inspect-brk", "${file}"],
      "attachSimplePort": 9229
    }
  ]
}

When I run deno test in VS Code, the debug console shows the following:

/home/kyle/.deno/bin/deno test --inspect-brk /mnt/c/Users/kylej/projects/deno/collections/example_test.ts
Debugger listening on ws://127.0.0.1:9229/ws/d3ee3abf-7713-45b0-a205-c4de417a5d76

The execution breaks immediately showing colors.ts file with the contents below. If I click continue it will continue to the first break point I set in the code.

Could not load source '/mnt/c/Users/kylej/projects/deno/collections/std@0.74.0/fmt/colors.ts': Unable to retrieve source content.

If I clicked step instead of continue, it would continue to opening _diff.ts showing the following content.

Could not load source '/mnt/c/Users/kylej/projects/deno/collections/std@0.74.0/testing/_diff.ts': Unable to retrieve source content.

If I keep clicking step instead of continue, it will continue to open other files with a similar message as above.

Soremwar commented 4 years ago

@KyleJune Can reproduce image

I'm using Manjaro Linux so I doubt OS has something to do with it

Soremwar commented 4 years ago

@caspervonb Tons of errors, not sure if any is related

Main._createAppUI: 25.945068359375 ms
main.js:1 Main._showAppUI: 8.56005859375 ms
main.js:1 Main._initializeTarget: 33.946044921875 ms
main.js:1 Main._lateInitialization: 0.802978515625 ms
protocol_client.js:1 Request Network.enable failed. {"code":-32601,"message":"'Network.enable' wasn't found"}
protocol_client.js:1 Request Page.enable failed. {"code":-32601,"message":"'Page.enable' wasn't found"}
protocol_client.js:1 Request Page.getResourceTree failed. {"code":-32601,"message":"'Page.getResourceTree' wasn't found"}
protocol_client.js:1 Request DOM.enable failed. {"code":-32601,"message":"'DOM.enable' wasn't found"}
protocol_client.js:1 Request CSS.enable failed. {"code":-32601,"message":"'CSS.enable' wasn't found"}
protocol_client.js:1 Request Overlay.enable failed. {"code":-32601,"message":"'Overlay.enable' wasn't found"}
protocol_client.js:1 Request Overlay.setShowViewportSizeOnResize failed. {"code":-32601,"message":"'Overlay.setShowViewportSizeOnResize' wasn't found"}
protocol_client.js:1 Request Log.enable failed. {"code":-32601,"message":"'Log.enable' wasn't found"}
protocol_client.js:1 Request Log.startViolationsReport failed. {"code":-32601,"message":"'Log.startViolationsReport' wasn't found"}
protocol_client.js:1 Request Emulation.setEmulatedMedia failed. {"code":-32601,"message":"'Emulation.setEmulatedMedia' wasn't found"}
protocol_client.js:1 Request Audits.enable failed. {"code":-32601,"message":"'Audits.enable' wasn't found"}
protocol_client.js:1 Request ServiceWorker.enable failed. {"code":-32601,"message":"'ServiceWorker.enable' wasn't found"}
protocol_client.js:1 Request Inspector.enable failed. {"code":-32601,"message":"'Inspector.enable' wasn't found"}
protocol_client.js:1 Request Target.setAutoAttach failed. {"code":-32601,"message":"'Target.setAutoAttach' wasn't found"}
protocol_client.js:1 Request Target.setDiscoverTargets failed. {"code":-32601,"message":"'Target.setDiscoverTargets' wasn't found"}
protocol_client.js:1 Request Target.setRemoteLocations failed. {"code":-32601,"message":"'Target.setRemoteLocations' wasn't found"}
protocol_client.js:1 Request Page.getNavigationHistory failed. {"code":-32601,"message":"'Page.getNavigationHistory' wasn't found"}
protocol_client.js:1 Request Page.startScreencast failed. {"code":-32601,"message":"'Page.startScreencast' wasn't found"}
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request Page.stopScreencast failed. {"code":-32601,"message":"'Page.stopScreencast' wasn't found"}
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request Page.setAdBlockingEnabled failed. {"code":-32601,"message":"'Page.setAdBlockingEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setFocusEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setFocusEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Page.startScreencast failed. {"code":-32601,"message":"'Page.startScreencast' wasn't found"}
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request Page.getNavigationHistory failed. {"code":-32601,"message":"'Page.getNavigationHistory' wasn't found"}
protocol_client.js:1 Request Overlay.setPausedInDebuggerMessage failed. {"code":-32601,"message":"'Overlay.setPausedInDebuggerMessage' wasn't found"}
protocol_client.js:1 Request Page.stopScreencast failed. {"code":-32601,"message":"'Page.stopScreencast' wasn't found"}
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request Page.startScreencast failed. {"code":-32601,"message":"'Page.startScreencast' wasn't found"}
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request DOM.getDocument failed. {"code":-32601,"message":"'DOM.getDocument' wasn't found"}
sdk.js:1 No document
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request DOM.getDocument failed. {"code":-32601,"message":"'DOM.getDocument' wasn't found"}
sdk.js:1 No document
protocol_client.js:1 Request DOM.getDocument failed. {"code":-32601,"message":"'DOM.getDocument' wasn't found"}
sdk.js:1 No document
protocol_client.js:1 Request Emulation.setTouchEmulationEnabled failed. {"code":-32601,"message":"'Emulation.setTouchEmulationEnabled' wasn't found"}
protocol_client.js:1 Request Emulation.setEmitTouchEventsForMouse failed. {"code":-32601,"message":"'Emulation.setEmitTouchEventsForMouse' wasn't found"}
protocol_client.js:1 Request Overlay.setPausedInDebuggerMessage failed. {"code":-32601,"message":"'Overlay.setPausedInDebuggerMessage' wasn't found"}
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Soremwar commented 3 years ago

I forgot about this. The stop is caused by passing --inspect-brk as a inspect argument instead of just --inspect. This is supposed to stop on the first line of code to execute so behavior is expected (though a little misleading, since I was actually expecting it to stop in the first line of my code but I guess it doesn't work that way).

papiro commented 2 years ago

This is actually occurring for me as well, but with the --inspect flag. Running a test in Visual Studio Code stops at the first line of colors.ts. When I push play then the debugger proceeds to my breakpoint. Everything is working correctly, but it is a bit annoying and I wish there was an option to just play it through to my breakpoint.

bartlomieju commented 2 years ago

This is actually occurring for me as well, but with the --inspect flag. Running a test in Visual Studio Code stops at the first line of colors.ts. When I push play then the debugger proceeds to my breakpoint. Everything is working correctly, but it is a bit annoying and I wish there was an option to just play it through to my breakpoint.

Please open a new issue with a preproduction.