-
Notifications
You must be signed in to change notification settings - Fork 511
Use in-memory debug adapter instead of spinning up new process #2672
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
Use in-memory debug adapter instead of spinning up new process #2672
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not my area of expertise but it seems like we are using more of VSCode's native facilities rather than our own custom solution. Sounds good to me.
private static readonly HEADER_LINESEPARATOR = /\r?\n/; // allow for non-RFC 2822 conforming line separators | ||
private static readonly HEADER_FIELDSEPARATOR = /: */; | ||
|
||
private _rawData = Buffer.allocUnsafe(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the initialisation here used for? I'm guessing there's somewhere we can pass in undefined and this is the cheapest way to pass in an empty buffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, this comes from VS Code's implementation that's quite challenging to fully understand... they also set this in the constructor... so I'm really unsure why.
src/debugAdapter.ts
Outdated
onDidSendMessage: Event<DebugProtocolMessage> = this._sendMessage.event; | ||
|
||
constructor(namedPipe: string, logger: Logger) { | ||
this._debugServiceSocket = connect(namedPipe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry a bit about objects that can't be constructed without connecting to an IPC stream, but really it's probably fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now the constructor does almost nothing and start() method does the connection.
private _isConnected: boolean = false; | ||
private _debugMessageQueue: DebugProtocolMessage[] = []; | ||
|
||
private _debugServiceSocket: Socket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these be added to the constructor for injection-initialisation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided against this because I wanted the _
prefix.
PR Summary
This leverages a newish feature in VS Code called a
DebugAdapter
type. I heard about it from this issue:microsoft/vscode#84643 (comment)
This gives us:
This partially solves #2358 because now, the debug adapter won't die... it'll kick the extension on and say "run it again in a bit once the extension fully starts"
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
x
between the square brackets.Please mark anything not applicable to this PR
NA
.WIP:
to the beginning of the title and remove the prefix when the PR is ready