Deno.run Strange Issue
I use
Deno.run
+ stdout/signals/etc a lot, but this behavior is beyond my current debugging abilities
I have a command nix eval ...
which works fine in a python subshell, and on the commandline. However, Deno.run with piped stdout makes it hang indefinitely. To be explicit, in this block: process.status().then(callback).catch(callback)
the callback doesn't run until a .kill()
is used (SIGHUP/SIGINT/SIGKILL). Tested on Deno 1.29.4 and Deno 1.22.0 for good measure.
What is even more strange is trying to bypass the problem with hackery also fails.
All of these round-about execution methods (translated to Deno.run) also hang indefinitely:
- bash -c '[command]'
- bash ./file_with_command.sh
- bash -i ./file_with_command.sh
In particular the bash -i
method not only hangs, but also exclusively makes it so that ctrl+C, ctrl+D, and even ctrl+Z are ignored; I have to kill the deno process from another termial.
Env: bash -c env
prints out the EXACT same env vars for Deno/Python/CLI
Cwd: deno/python/cli all have the same working directory
Interactivity: running it with deno repl
has been the same as deno run
Piping:
Manually closing the stdout pipe doesn't work/help.
Removing stdout: 'piped'
, makes command not-hang (but defeats the point).
Adding stderr: 'piped'
still causes a hang.
I don't even know what else could be possibly causing a difference (Deno & Python code attached as comments)7 Replies
Here's the deno code (does need nix: https://nixos.org/download.html ):
And here is the python for comparison
And for good measure here is also Ruby code, which also doesn't hang
I haven't had a chance to look into why this might be hanging, but I will point out that
Deno.run
is being deprecated in favor of Deno.Command
which has an objectively clearer api. I will look into this when I get the chanceDeno.run
does have some hanging issue as well. If memory serves then one way around it is to await Promise.all()
all the three outputs of the run, not only status but stdout and stderr as well.I was looking into that but are there docs for Deno.Command? I expanded every section on https://deno.land/api@v1.30.3 and ctrl+f still returns nothing
It also doesn't seem to exist on 1.29.4
wow... this actually works/doesnt hang. Thanks @aapoalas
It's probably still under the "unstable" checkbox. IIRC the PR stabilising it has only just been merged or is about to be.
It is going to be part of
v1.31.0
iirc