fix(vitest): strip non-serializable functions from inline diff config#10573
Merged
sheremet-va merged 2 commits intoJun 12, 2026
Merged
Conversation
An inline `test.diff` object can carry color/compareKeys functions (`DiffOptions`). `serializeConfig` forwarded the raw object to the worker pool, so the config failed to cross the worker boundary: the `threads` pool threw `DataCloneError` on structured clone and the `forks` pool threw on `child_process` IPC serialization. Every run with an inline diff object that included a color function crashed the worker. Forward only the serializable fields declared by `SerializedDiffOptions`, matching the existing contract (the file-path form still imports the function-based options locally in the worker). Fixes vitest-dev#8663
The previous commit returned every SerializedDiffOptions field, so unset
options became explicit `undefined` values that clobbered the diff defaults
when the worker merged the options — breaking inline options like
`{ expand: true }` and `{ printBasicPrototype: true }` (caught by
test/diff.test.ts in CI). Copy only the keys that are actually set.
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Author
|
CI status after 534e99b: all Build&Test and Cache&Test jobs are green — the earlier The remaining red jobs are the timing-sensitive |
sheremet-va
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #8663.
When
test.diffis given as an inline object, it may contain color/compareKeysfunctions (the publicDiffOptionstype).serializeConfigforwarded that object to the worker pool verbatim:Because functions are not serializable across the worker boundary, every run with an inline diff object that includes a function crashed the worker before any test ran:
threads/vmThreads→DataCloneErroronpostMessagestructured cloneforks/vmForks→(s) => s could not be clonedonchild_processIPCThe string (file-path) form was unaffected because only a string is serialized and the worker imports the module locally in
loadDiffConfig.Fix
Strip the object down to the serializable fields already declared by
SerializedDiffOptionsbefore sending it to workers. This honors the existing contract —SerializedDiffOptionsdeliberately omits every*Color/compareKeysfunction field — andloadDiffConfigalready accepts an objectdiffand uses it as-is. The function-based options continue to work via the file-path form, which the worker imports locally.Tests
Added a regression test in
test/e2e/test/reporters/custom-diff-config.test.tsthat runs with an inline diff object containing both serializable annotations and a color function, across theforksandthreadspools. It asserts the run no longer crashes withcould not be clonedand that the serializable annotations are still applied.Verified the test fails without the fix (both pools throw
could not be cloned) and passes with it.