-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
No error diff color on forks pool #7042
Comments
It turned out this is due to tinypool v1.0.2 tinylibs/tinypool#104.
@AriPerkkio Do you have some idea for fix? Btw, |
Good catch @hi-ogawa, I wasn't expecting this. Here's minimal reproduction without Tinypool demonstrating the fix from tinylibs/tinypool#104. Happy to change the implementation if another approach is found: Intercept stdout of node:child_process in main processimport { writeFileSync } from "node:fs";
import { fork } from "node:child_process";
import { setTimeout } from "node:timers/promises";
writeFileSync(
"./worker.mjs",
`
process.stdout.write("Message\\n");
process.stderr.write("Error message\\n");
`.trim(),
"utf8"
);
const write = process.stdout.write.bind(process.stdout);
process.stdout.write = (data) => {
write(`Captured stdout: ${data}`);
};
process.stderr.write = (data) => {
write(`Captured stderr: ${data}`);
};
{
// Unable to intercept stdout
const subprocess = fork("./worker.mjs");
await setTimeout(3_000);
subprocess.kill();
}
{
// Intercepts stdout
const subprocess = fork("./worker.mjs", { stdio: "pipe" });
subprocess.stdout.pipe(process.stdout);
subprocess.stderr.pipe(process.stderr);
await setTimeout(3_000);
subprocess.kill();
} Intercept stdout of node:worker_threads, works automaticallyimport { writeFileSync } from "node:fs";
import { Worker } from "node:worker_threads";
import { setTimeout } from "node:timers/promises";
writeFileSync(
"./worker.mjs",
`
process.stdout.write("Message\\n");
process.stderr.write("Error message\\n");
`.trim(),
"utf8"
);
const write = process.stdout.write.bind(process.stdout);
process.stdout.write = (data) => {
write(`Captured stdout: ${data}`);
};
process.stderr.write = (data) => {
write(`Captured stderr: ${data}`);
};
const worker = new Worker("./worker.mjs");
await setTimeout(3_000);
await worker.terminate(); |
I guess we could pass down some flag |
Yup that should work! It makes sense that TTY checks start to fail after changing the streams. Not sure why colors should be disabled when TTY is disabled though. |
@sheremet-va what do you think about having It could be used in cases like this, where main thread/process is TTY but spawned processes' streams aren't. |
Describe the bug
Not sure why I just noticed this now, but it looks like we don't have diff color on forks.
https://stackblitz.com/edit/vitest-dev-vitest-cnfjynoc?file=test%2Fbasic.test.ts
npm run test
npm run test --pool threads
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-cnfjynoc?file=test%2Fbasic.test.ts
System Info
System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.20.3 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm npmPackages: vitest: 2.1.8 => 2.1.8
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: