Comments (7)
You're welcome! This is now released in 0.11.0. I'm not sure if there's anything we can do to mitigate this when capturing the output unfortunately.
from dax.
I believe my change in...
...should mitigate this issue. I was using async writers everywhere, but it wasn't necessary.
from dax.
By default, stdout and error are always captured. What may occur is the sub process writes to stdout, stderr, then stdout, but only then does the process running dax start reading which could read all the data in stdout at once, then after all the data in stderr. I don't think there's any way around this since stdout and stderr are two separate pipes. I think the same issue could occur in zx, but maybe the chances are lower because node uses callbacks? https://github.com/google/zx/blob/700bd4cae2ce564aa477b2501b1916c2a9041a85/src/core.ts#L208-L222
if I inherit the streams from the parent process as...
Yeah, if you inherit then it the subprocess will write directly to the deno process's stdout and err, which won't rely on the javascript code waking up and reading from stdout and stderr, storing it, then outputing. If you want to change the default you can do:
import {
build$,
CommandBuilder,
} from "...";
const commandBuilder = new CommandBuilder()
.stdout("inherit")
.stderr("inherit");
const $ = build$({ commandBuilder });
from dax.
@dsherret Got it, this makes sense, and I bet you're right in your guess about zx
!
Out of curiosity, did you consider making the io
streams inherited by default and piped as an option?
Thanks for the info and follow up on this - cheers!
Edit: I just ran a test with zx
and it does indeed print in the "correct" order - I bet you're right about it being less likely to happen given how node uses callbacks. I wonder what it would take to make it print out of order....maybe larger chunks of data written at once so it can't flush the whole buffer at once? Anyway, interesting!
from dax.
Out of curiosity, did you consider making the io streams inherited by default and piped as an option?
I think that would be better because of the existence of the "helper" functions (like $`some_command`.text()
) that could automatically change to piped when necessary. I'll do that right now.
from dax.
Awesome! Thanks for taking a look at this and as always, thank you very much for your work on this (and the Deno ecosystem) 😄
from dax.
Nice! Yea, given my new understanding of how this works, I suspect you're right. I will go ahead and close this issue as "that's just kinda how it works" 😄
Fortunately, the new default provides the behavior I expected intuitively, so that's great! Cheers!
from dax.
Related Issues (20)
- Logging object as argument should not print [object Object]
- Upgrade dependency deno_task_shell to 0.14.2
- Merged streams make it unable to access streams HOT 1
- Panic on stderr redirect
- Make it easier to pipe to files HOT 3
- Patch for deprecation warnings in console/utils.ts HOT 2
- Redesign command and internal streams
- Ability to cancel a request HOT 1
- Support for subshells breaks escaped parentheses HOT 1
- Rename `PathRef` to `Path`
- Support providing a `CommandBuilder` to a template literal expr HOT 1
- built-in 'cat' command does not work with absolute paths
- Add `.linesIter()`
- Support glob expansion
- Path - Copy dir recursive
- Strict typing for arguments HOT 1
- Strange issue when upgrading Deno HOT 3
- $.prompt doesn't support utf-8? HOT 1
- add command for `tar` HOT 2
- imagemagick hangs 😞
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dax.