Skip to content

Commit 78363a1

Browse files
fix error serialization in parallel mode (#1053)
1 parent 2089c60 commit 78363a1

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
"mz": "^2.4.0",
156156
"progress": "^2.0.0",
157157
"resolve": "^1.3.3",
158+
"serialize-error": "^2.1.0",
158159
"stack-chain": "^2.0.0",
159160
"stacktrace-js": "^2.0.0",
160161
"string-argv": "0.0.2",

src/runtime/parallel/slave.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import _ from 'lodash'
12
import { formatLocation } from '../../formatter/helpers'
23
import commandTypes from './command_types'
34
import EventEmitter from 'events'
45
import Promise from 'bluebird'
56
import readline from 'readline'
7+
import serializeError from 'serialize-error'
68
import StackTraceFilter from '../stack_trace_filter'
79
import supportCodeLibraryBuilder from '../../support_code_library_builder'
810
import TestCaseRunner from '../test_case_runner'
@@ -18,6 +20,13 @@ const EVENTS = [
1820
'test-case-finished',
1921
]
2022

23+
function replacerSerializeErrors(key, value) {
24+
if (_.isError(value)) {
25+
return serializeError(value)
26+
}
27+
return value
28+
}
29+
2130
export default class Slave {
2231
constructor({ cwd, stdin, stdout }) {
2332
this.initialized = false
@@ -29,7 +38,10 @@ export default class Slave {
2938
EVENTS.forEach(name => {
3039
this.eventBroadcaster.on(name, data =>
3140
this.stdout.write(
32-
JSON.stringify({ command: commandTypes.EVENT, name, data }) + '\n'
41+
JSON.stringify(
42+
{ command: commandTypes.EVENT, name, data },
43+
replacerSerializeErrors
44+
) + '\n'
3345
)
3446
)
3547
})

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3695,6 +3695,10 @@ [email protected]:
36953695
range-parser "~1.2.0"
36963696
statuses "~1.3.1"
36973697

3698+
serialize-error@^2.1.0:
3699+
version "2.1.0"
3700+
resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-2.1.0.tgz#50b679d5635cdf84667bdc8e59af4e5b81d5f60a"
3701+
36983702
serve-static@^1.10.0:
36993703
version "1.13.1"
37003704
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719"

0 commit comments

Comments
 (0)