thread-stream
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -34,2 +34,5 @@ 'use strict' | ||
// No .catch() handler, | ||
// in case there is an error it goes | ||
// to unhandledRejection | ||
start().then(function () { | ||
@@ -41,6 +44,2 @@ parentPort.postMessage({ | ||
process.nextTick(run) | ||
}).catch(function (err) { | ||
// TODO transfer this to main? | ||
console.error(err) | ||
process.exit(1) | ||
}) | ||
@@ -90,1 +89,7 @@ | ||
} | ||
process.on('unhandledRejection', function (err) { | ||
// TODO transfer this to main | ||
console.error(err) | ||
process.exit(1) | ||
}) |
{ | ||
"name": "thread-stream", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "A streaming way to send data to a Node.js Worker Thread", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,1 +49,57 @@ 'use strict' | ||
}) | ||
test('emit error if thread exits', async function (t) { | ||
const stream = new ThreadStream({ | ||
filename: join(__dirname, 'exit.js'), | ||
sync: true | ||
}) | ||
stream.on('ready', function () { | ||
stream.write('hello world\n') | ||
}) | ||
const [err] = await once(stream, 'error') | ||
t.equal(err.message, 'The worker thread exited') | ||
try { | ||
stream.write('noop') | ||
t.fail('unreacheable') | ||
} catch (err) { | ||
t.equal(err.message, 'the worker has exited') | ||
} | ||
try { | ||
stream.write('noop') | ||
t.fail('unreacheable') | ||
} catch (err) { | ||
t.equal(err.message, 'the worker has exited') | ||
} | ||
}) | ||
test('emit error if thread have unhandledRejection', async function (t) { | ||
const stream = new ThreadStream({ | ||
filename: join(__dirname, 'unhandledRejection.js'), | ||
sync: true | ||
}) | ||
stream.on('ready', function () { | ||
stream.write('hello world\n') | ||
}) | ||
const [err] = await once(stream, 'error') | ||
t.equal(err.message, 'The worker thread exited') | ||
try { | ||
stream.write('noop') | ||
t.fail('unreacheable') | ||
} catch (err) { | ||
t.equal(err.message, 'the worker has exited') | ||
} | ||
try { | ||
stream.write('noop') | ||
t.fail('unreacheable') | ||
} catch (err) { | ||
t.equal(err.message, 'the worker has exited') | ||
} | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31081
22
1046