-
Notifications
You must be signed in to change notification settings - Fork 803
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
🐛 BUG: Can't pipe to wrangler secret put
#1303
Comments
What shell/console are you reproducing this under? Anyone know what environment can cause this? I use Windows 11 with Ubuntu 22.04 in WSL for almost all of my development work and never had this problem (Piped a secret earlier today) |
@Erisa I've been able to repro in both the integrated terminal in VSC Insiders (Windows 11 + bash), and Windows Terminal Preview (bash) on both Windows and Ubuntu 22.04 LTS under WSL. |
We have specifically code to workaround this, so I'm surprised to hear of this failure. Could you run these two commands in your terminal for me and tell me what you see? node -e "console.log(process.stdin.isTTY)" and echo 123 | node -e "console.log(process.stdin.isTTY)" |
This is what I see -
|
@threepointone Running those two commands on Windows (VSC Insiders / Windows Terminal Preview + Bash) returns this:
However, running the same commands on Ubuntu 22.04 WSL (Windows Terminal Preview + Bash) returns this:
|
So it seems that in Cygwin/MING64/"Git bash" environments instead of returning I haven't got my Windows machine to hand to test this. This seems to be a bug in how node is interfacing with the terminal. But if this is the case, we could be a bit more tolerant and change the following function: https://github.com/cloudflare/wrangler2/blob/1d778ae16c432166b39dd6435a4bab49a2248e06/packages/wrangler/src/user/user.tsx#L1131-L1133 To be something like: function isInteractive(): boolean {
try {
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
} catch {
return false;
}
} |
Yeah, looking at a few Node.js issues, including nodejs/node#3006, it seems as if Node itself doesn't play well with winpty. However, running the commands in #1303 (comment) while appending .exe (which bypasses winpty) to Node makes Node return
This code change seems to have worked when testing it out locally on all the environments I've reproduced this issue on. |
* fix: Fallback to non-interactive mode on error If the terminal isn't a TTY, fallback to non-interactive mode instead of throwing an error. This makes it so users of Bash on Windows can pipe to wrangler without an error being thrown. resolves #1303 Signed-off-by: William Horning <[email protected]> * Fix formatting and add tests Signed-off-by: William Horning <[email protected]> * fixup! Fix formatting and add tests Co-authored-by: Pete Bacon Darwin <[email protected]>
What version of
Wrangler
are you using?2.0.7 and 2.0.14
What operating system are you using?
Windows and Ubuntu 22.04 on WSL
Describe the Bug
When trying to pipe data from a file to
wrangler secret put
usingcat secret.txt | wrangler secret put SECRET
, wrangler returns an error from vadimdemedes/ink with the following text:I am able to reproduce this under Windows and Ubuntu 22.04 on WSL in both Wrangler 2.0.7 and Wrangler 2.0.14, in addition to other users in past issues.
The text was updated successfully, but these errors were encountered: