microsoft / vscode-debugadapter-node

Debug adapter protocol and implementation for VS Code.
Other
273 stars 79 forks source link

inStream.resume is not a function in protocol.ts/js #140

Closed mikeseese closed 6 years ago

mikeseese commented 7 years ago

I've been following the tutorial at https://code.visualstudio.com/docs/extensions/example-debuggers and modifying the mock debugger at https://github.com/Microsoft/vscode-mock-debug to add a new debug adapter. However, when I try to run my debugger I get an error:

Activating extension `seesemichaelj.vscode-sdb-debug` failed: inStream.resume is not a function.

I put a breakpoint in the protocol module and it seemed that inStream was of type stream.Writable, almost as if it was from subprocess.stdin instead of process.stdin. I backtracked in the stack to the DebugSession.run(...) where it passes in the inStream variable, I see it is process.stdin in the code; evaluating process.stdin in that context also returns a Writable type.

However, when I run the mock-debug example from source without changing anything, I am able to step through a README.md file with no issues.

I'm using Node v8.9.1, NPM v5.5.1 and vscode-debugadapter v1.25.0-pre.3 (see npm list call below)

npm list | grep vscode-debug
├─┬ vscode-debugadapter@1.25.0-pre.3
│ └── vscode-debugprotocol@1.25.0-pre.3 deduped
├─┬ vscode-debugadapter-testsupport@1.24.0
│ └── vscode-debugprotocol@1.24.0
└── vscode-debugprotocol@1.25.0-pre.3

I'm fairly certain I'm doing something wrong, but I'm having difficulty finding it (and my Google-fu is not turning up anything interesting). I can post this on Stackoverflow instead if this isn't the right place (its probably not the right place, but this may be an issue with the repo vs my code).

Thanks!

mikeseese commented 7 years ago

Maybe I didn't do all of my homework yet; reading more about the debug protocol/etc.

Edit: After further research, I'm still unsure how to solve this issue. However, it appears this issue is not preventing me from testing the debug adapter; I am able to continue using the debug adapter as if the issue wasn't occurring.

weinand commented 6 years ago

I will investigate next week (after the December release is done).

mikeseese commented 6 years ago

Well; looks like I had a brain-lapse when going through the debug adapter guide.

I guess when I read the following:

since the implementation of debug extension lives in the debug adapter, there is no need to have extension code at all

I thought that I didn't need an extension.ts-like file. Since I omitted this file, I wasn't sure what to put as my main value in package.json; so I put my sdbDebug.ts file there. This causes it to get loaded as a module when activating the extension, which in turn runs the DebugSession.run() function under the extension process.

This is obviously a "ya, that's not going to work" moment; the error was happening because the extension process was a subprocess and therefore process.stdin was Writable (https://nodejs.org/api/child_process.html#child_process_subprocess_stdin would be the documentation).

TL;DR: The issue was due to me putting the debug file as the main program for the extension instead of an extension program.

Thanks anyway!