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
Fix #15: debugging session closes silently #23
Conversation
I am waiting for the original reporter of this problem to test that this fix closes #15. |
if (debuggerStatus === (DebuggerStatus.running as DebuggerStatus)) { | ||
await new Promise<void>((resolve) => setTimeout(resolve, 500)); // Wait for a fraction of a second more, to allow TCP/IP port to initialize in probe-rs-debugger | ||
} |
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.
Not directly related to this PR, but what is the reason to use a TCP connection by default?
It seems easier to me to just use stdout to communicate, which requires less setup.
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 how I originally had it. I discovered it became unstable (mostly lost requests/responses), which were not reproducible over TCP.
Once I made the changeover, I also found it opened the opportunity to pipe RUST_LOG output to the user's VSCode console, so I figured it was worth the extra effort at extension development time.
What do you mean "requires less setup"?
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.
With stdout, I would assume that that we don't need to wait for any setup, and it would also not be required to find a suitable port to communicate.
The logs are sent to stderr AFAIk, so catching them should still be possible.
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.
Yep, like I said, that is how I had it working. I implemented the TCP by default based on some posts I found where other extension developers saw similar instability with the STDIO version.
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'm a bit surprised that STDIO is unstable, but have no reason to doubt it :)
Could you add a comment to explain this? Just to avoid similar questions in the future. Thanks!
if (debuggerStatus === (DebuggerStatus.running as DebuggerStatus)) { | ||
await new Promise<void>((resolve) => setTimeout(resolve, 500)); // Wait for a fraction of a second more, to allow TCP/IP port to initialize in probe-rs-debugger | ||
} |
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'm a bit surprised that STDIO is unstable, but have no reason to doubt it :)
Could you add a comment to explain this? Just to avoid similar questions in the future. Thanks!
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.
Thanks!
bors r+ |
Build succeeded: |
This fix for #15 includes the following:
code
, also check for the possibility of a processsignal
.probe-rs-debugger
process was started withchild_process.execFile
, which has a defaultmaxBuffer
for stdio of1024 * 1024
. When the stdout or stderr (RUST_LOG output is handled this way) exceeded this, VSCode would terminate the process and truncate the output ... and because we didn't test thesignal
, we never saw theSIGTERM
event happening, and it looked as if theprobe-rs-debugger
failed silently. I have changed this to usechild_process.spawn
, which usesStream
objects instead ofBuffer
objects to handle the stdio from the child process.