Skip to content

Commit

Permalink
feat: use devalue for serialization inside child process
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 21, 2023
1 parent dbbbb8e commit 5697f4f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/vitest/package.json
Expand Up @@ -126,6 +126,7 @@
"cac": "^6.7.14",
"chai": "^4.3.7",
"debug": "^4.3.4",
"devalue": "^4.3.0",
"local-pkg": "^0.4.2",
"pathe": "^1.1.0",
"picocolors": "^1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/node/pools/child.ts
@@ -1,7 +1,7 @@
import v8 from 'node:v8'
import type { ChildProcess } from 'node:child_process'
import { fork } from 'node:child_process'
import { fileURLToPath, pathToFileURL } from 'node:url'
import * as devalue from 'devalue'
import { createBirpc } from 'birpc'
import { resolve } from 'pathe'
import type { RuntimeRPC } from '../../types'
Expand All @@ -17,8 +17,8 @@ function setupChildProcessChannel(ctx: Vitest, fork: ChildProcess) {
createBirpc<{}, RuntimeRPC>(
createMethodsRPC(ctx),
{
serialize: v8.serialize,
deserialize: v => v8.deserialize(Buffer.from(v)),
serialize: devalue.stringify,
deserialize: devalue.parse,
post(v) {
fork.send(v)
},
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/runtime/child.ts
@@ -1,6 +1,6 @@
import v8 from 'node:v8'
import { relative, resolve } from 'pathe'
import { createBirpc } from 'birpc'
import * as devalue from 'devalue'
import { processError } from '@vitest/runner/utils'
import { ModuleCacheMap } from 'vite-node/client'
import { isPrimitive } from 'vite-node/utils'
Expand Down Expand Up @@ -88,8 +88,8 @@ function init(ctx: ChildContext) {
{},
{
eventNames: ['onUserConsoleLog', 'onFinished', 'onCollected', 'onWorkerExit'],
serialize: v8.serialize,
deserialize: v => v8.deserialize(Buffer.from(v)),
serialize: devalue.stringify,
deserialize: devalue.parse,
post(v) {
process.send?.(v)
},
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5697f4f

Please sign in to comment.