Skip to content
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

Piping into VS Code fails if data writes delayed #155341

Closed
corydodt opened this issue Jul 15, 2022 · 13 comments
Closed

Piping into VS Code fails if data writes delayed #155341

corydodt opened this issue Jul 15, 2022 · 13 comments
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded workbench-cli VS Code Command line issues
Milestone

Comments

@corydodt
Copy link

corydodt commented Jul 15, 2022

Does this issue occur when all extensions are disabled?: Yes*

*This bug can only appear while using the Remote:SSH extension, as far as I can tell. I have reproduced it having ONLY that extension installed, and no others.

  • VS Code Version: Version: 1.69.1 (Universal)
  • I have also reproduced this issue with VSC Insiders Version: 1.70.0-insider (Universal)
  • OS Version: Darwin x64 20.5.0
  • OS Version (remote): Linux aero-dev-202204071826 5.17.0-1-amd64 Open Source VS Code #1 SMP PREEMPT Debian 5.17.3-1 (2022-04-18) x86_64 x86_64 x86_64 GNU/Linux
    Steps to Reproduce:
  1. Remote SSH: Connect current window to host...
  2. Select a host and connect
  3. Create new terminal
  4. Shell Command: Install 'code' command in PATH
  5. In the shell: ls -l | code -

What happens
This opens a tab in the current editor window, but the tab stays empty, no output is sent there.

What I expected
The new opened tab contains the text of whatever was written to stdout by ls -l

Additional troubleshooting

  • this was working with all commands, in the same context, as recently as the previous update.
  • If I do not connect to a remote and use a terminal on the local machine (a macbook), cmd | code - works fine.
  • It doesn't fail 100% of the time, more like 90%. Occasionally a command will write some output to the window.
  • code filename.txt still works as expected
  • This is not specific to ls, any attempt to pipe stdout to code - with any command has the same behavior.
@roko99
Copy link

roko99 commented Jul 18, 2022

Hello! I have quite similar issue with:

Version: 1.69.1
Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a
Date: 2022-07-12T08:28:29.328Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Linux x64 5.18.11-200.fc36.x86_64

Its not happen with each executed command. For me its happen when command execution takes about ~1sec. To reproduce it you can try create simple script like (I'm using bash):

#!/bin/bash

sleep $1 ; ls -l

then play with sleep time:

bash test.sh 1 | code -

File in /tmp is created:

[v.prokopenko@vprokopenko-work ~]$ cat /tmp/code-stdin-EJS
total 24
-rw-r--r--. 1 v.prokopenko v.prokopenko  271 Mar 29 13:40 kustomization.yaml
drwxr-xr-x. 1 v.prokopenko v.prokopenko  112 Mar 29 13:40 mysql
-rw-r--r--. 1 v.prokopenko v.prokopenko  533 Mar 29 13:40 patch.yaml
-rw-r--r--. 1 v.prokopenko v.prokopenko 3911 Mar 29 13:40 README.md
-rw-r--r--. 1 v.prokopenko v.prokopenko   65 Jul 18 15:44 test1.yaml
-rw-r--r--. 1 v.prokopenko v.prokopenko   30 Jul 18 15:45 test.sh
-rw-r--r--. 1 v.prokopenko v.prokopenko 2127 Jul 18 15:41 test.yaml
drwxr-xr-x. 1 v.prokopenko v.prokopenko   90 Mar 29 13:40 wordpress

but in VSCode I see a "fresh" one:
vscode

Please let me know if I'm facing with another problem and should create new issue.

UPD.
After downgrade to my previous version - 1.66.2, works fine.

@Tyriar Tyriar assigned bpasero and unassigned Tyriar Jul 18, 2022
@bpasero bpasero assigned roblourens and aeschli and unassigned bpasero Jul 18, 2022
@bpasero bpasero added remote Remote system operations issues workbench-cli VS Code Command line issues labels Jul 18, 2022
@bpasero
Copy link
Member

bpasero commented Jul 18, 2022

I am not sure we ever supported this in remote.

@roko99
Copy link

roko99 commented Jul 18, 2022

Sorry guys, I didn't mentioned - my case is on local machine.

@bpasero
Copy link
Member

bpasero commented Jul 18, 2022

Let's keep this issue for running code - from a remote terminal from a window that is connected to the remote.

@roblourens roblourens removed their assignment Jul 18, 2022
@vec4f
Copy link

vec4f commented Jul 18, 2022

I'm running into this issue as well.

  • Version: 1.69.1 (user setup)
  • Commit: b06ae3b
  • Date: 2022-07-12T08:21:24.514Z
  • Electron: 18.3.5
  • Chromium: 100.0.4896.160
  • Node.js: 16.13.2
  • V8: 10.0.139.17-electron.0
  • OS: Windows_NT x64 10.0.19043
  • OS (remote): Ubuntu 20.04 WSL2
$ ls -l | code -
Reading from stdin via: /tmp/code-stdin-eLG

When the new tab opens up in my window, it's showing the path of \tmp\code-stdin-eLG instead of /tmp/code-stdin-eLG. If I manually open the temp file at that path, I see the output of the command as expected. This seems to indicate that, at least on WSL2, there is some remapping of slashes into backslashes somewhere that makes VS Code unable to open the proper output file.

@tyoshino
Copy link

I'm having the same issue (initially filed as #155129).

My case is about remote connections (connecting to a VM on Google Cloud), but have the same condition as @roko99. It rarely happens for echo, cat, etc. which completes immediately, but happens for ones with some delay such as curl, kubectl, etc.

My case is about Windows connecting to Linux as well as @vec4f. Yes, the path showing up on the tab has backslashes instead of slashes.

@bpasero
Copy link
Member

bpasero commented Aug 2, 2022

I cannot reproduce this and the command to install code as shell command seems wrong, that command is meant for installing VS Code on the OS. If you connect remotely to a host with VS Code, you should see code and code-insiders be there by default.

Here is proof:
Recording 2022-08-02 at 14 16 58

@bpasero bpasero added the info-needed Issue requires more information from poster label Aug 2, 2022
@tyoshino
Copy link

tyoshino commented Aug 2, 2022

@bpasero could you please try a command with some delay before sending out EOF?

E.g.

python -c "print 'a';import time;time.sleep(1)" | code-insiders -

shell command seems wrong

My case is using the code binary installed by the remote extension (it's saying 1.68.1 because I'm sticking my installation to the version without an issue except when I'm building the reproduction case).

$ code --version
1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64
$ which code
/home/takeshi/.vscode-server/bin/30d9c6cd9483b2cc586687151bcbcd635f373630/bin/remote-cli/code

@tyoshino
Copy link

tyoshino commented Aug 2, 2022

Here's a capture
Visual Studio Code - Insiders 2022-08-02 23-54-53

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster remote Remote system operations issues labels Aug 3, 2022
@bpasero bpasero assigned bpasero and unassigned aeschli Aug 3, 2022
@bpasero bpasero added this to the August 2022 milestone Aug 3, 2022
@bpasero bpasero changed the title code shell command can no longer accept piped stdin Piping into Code fails if data writes delayed Aug 3, 2022
@bpasero
Copy link
Member

bpasero commented Aug 3, 2022

This is likely a regression from my change in bf757ca then. fs.createWriteStream is creating the file if it does not exist, probably sync (not sure) and after my change we only create the file when data is received.

@bpasero
Copy link
Member

bpasero commented Aug 3, 2022

To repro:

  • run node --eval "setTimeout(() => console.log('hello world'), 10000)" | code-insiders -
  • verify hello world appears after those 10 seconds in the editor

@bpasero bpasero closed this as completed in f8ae10c Aug 3, 2022
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Aug 3, 2022
@vscodenpa vscodenpa added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Aug 5, 2022
@bpasero bpasero added the author-verification-requested Issues potentially verifiable by issue author label Aug 5, 2022
@vscodenpa
Copy link

This bug has been fixed in the latest release of VS Code Insiders!

@corydodt, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version 73fd3f1 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@tyoshino
Copy link

tyoshino commented Aug 8, 2022

Not the original reporter, but I verified that it's fixed on the following insider version.

Thank you so much!

Version: 1.71.0-insider (user setup)
Commit: b0895f9fcc5b49587a2b187a92bbe6d7efae35fa
Date: 2022-08-08T05:18:03.799Z
Electron: 19.0.11
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: Yes

@bpasero bpasero added the verified Verification succeeded label Aug 8, 2022
@gregvanl gregvanl changed the title Piping into Code fails if data writes delayed Piping into VS Code fails if data writes delayed Aug 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded workbench-cli VS Code Command line issues
Projects
None yet
Development

No branches or pull requests

9 participants