Skip to content

Conversation

@anthonykim1
Copy link

@anthonykim1 anthonykim1 commented Dec 15, 2025

Resolves: microsoft/vscode-python-environments#958

Challenge is that sendText would get called when terminal is not ready. And doing undefined.show() is the problem.
Switching to queue based execution for running REPL commands, which would prevent from us losing the first command as well.

@anthonykim1 anthonykim1 added this to the December / January 2026 milestone Dec 15, 2025
@anthonykim1 anthonykim1 self-assigned this Dec 15, 2025
@anthonykim1 anthonykim1 changed the title Anthonykim1/prevent undefined show Prevent Cannot read properties of undefined ('show') when running Python code Dec 15, 2025
@anthonykim1 anthonykim1 marked this pull request as draft December 15, 2025 18:29
const terminal = this.terminal!;
// TODO: First execution of shift+enter may get ignored when using sendText.
// Prevent Cannot read properties of undefined: https://github.com/microsoft/vscode-python-environments/issues/958
if (!this.terminal) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this actually queue it up using a worker queue? rather than returning undefined. essentially, wait for terminal to be ready, then when it does get ready, start executing. Until, then all the commands just get added to the queue. This way you can return a promise, that could eventually execute.

Copy link
Author

@anthonykim1 anthonykim1 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but would this queue also work for synchronous runs? @karthiknadig
I think the problem is that sendText (synchronous) gets called, when terminal is undefined and when its synchronous (sendText), it doesnt really wait for anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this function return a promise regardless of sendText or executeCommand?

Copy link
Author

@anthonykim1 anthonykim1 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try to come up with way we can actually detect when REPL is launched, maybe that will let us use the queue approach.

@anthonykim1 anthonykim1 added the bug Issue identified by VS Code Team member as probable bug label Dec 15, 2025
@anthonykim1 anthonykim1 added the important Issue identified as high-priority label Dec 16, 2025
@anthonykim1 anthonykim1 reopened this Dec 16, 2025
@anthonykim1 anthonykim1 marked this pull request as ready for review December 16, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-terminal bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of undefined (reading 'show')

3 participants