Describe the bug
if you have some code that might be invoked in fork, and if it checks for process.send, this will be true when vitest is running in forks mode. vitest will assume every message from process.send can be deserialised with Buffer.from, which can lead to errors.
I am currently working around by checking process.title but this may be fragile - perhaps there could be (or is?) an official way to check whether we are in a child proces we have invoked, or whether vitest has invoked it...
you may also have another suggestion
originally reported in #7082.
Reproduction
https://stackblitz.com/edit/node-fvacfgbn
// in user code
import process from 'node:process'
if (process.send) {
// this will be received by vitest's birpc
process.send({
type: 'foo',
})
}
export const thing = 42
System Info
Used Package Manager
pnpm
Validations
Describe the bug
if you have some code that might be invoked in fork, and if it checks for
process.send, this will be true when vitest is running in forks mode. vitest will assume every message from process.send can be deserialised withBuffer.from, which can lead to errors.I am currently working around by checking
process.titlebut this may be fragile - perhaps there could be (or is?) an official way to check whether we are in a child proces we have invoked, or whether vitest has invoked it...you may also have another suggestion
originally reported in #7082.
Reproduction
https://stackblitz.com/edit/node-fvacfgbn
System Info
Used Package Manager
pnpm
Validations