Skip to content

Commit 97dc8d8

Browse files
committed
test: catch the promise rejections in function processes
1 parent c2c9f90 commit 97dc8d8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

test/unit/helpers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ export function createProcess(fn: () => void): Promise<Result> {
155155
const src = `
156156
const zmq = require(${JSON.stringify(path.resolve(__dirname, "../.."))})
157157
const fn = ${fn.toString()}
158-
fn()
158+
const result = fn()
159+
if (result instanceof Promise) {
160+
result.catch(err => {
161+
throw err
162+
})
163+
}
159164
`
160165

161166
const child = spawn(process.argv[0], ["--expose_gc"])

test/unit/socket-send-receive-test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
248248
it("should deliver messages coercible to string", async function () {
249249
const messages = [
250250
null,
251-
function () {
252-
// nothing
253-
},
251+
function () {},
254252
16.19,
255253
true,
256254
{},

0 commit comments

Comments
 (0)