-
-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
Vitest's reporters go crazy when we cannot control how to print worker's process.stdout and process.stderr in main thread. These can be for example NodeJS deprecation warnings.
// main.mjs
import { URL } from 'node:url'
import Tinypool from 'tinypool'
const write = process.stdout.write.bind(process.stdout)
process.stdout.write = (data) => {
write(`Captured stdout: ${data}\n`)
}
process.stderr.write = (data) => {
write(`Captured stderr: ${data}\n`)
}
const pool = new Tinypool({
runtime: 'child_process',
filename: new URL('./worker.mjs', import.meta.url).href,
})
await pool.run()
// worker.mjs
export default function run() {
process.stdout.write('Message')
process.stderr.write('Error message')
}$ node main.mjs
Message
Error messageWith runtime: 'worker_threads':
$ node main.mjs
Captured stdout: Message
Captured stderr: Error messageReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels