thread-stream
Advanced tools
Comparing version 0.13.2 to 0.14.0
10
index.js
@@ -107,2 +107,7 @@ 'use strict' | ||
stream.flush(() => { | ||
// err is already handled in flush() | ||
if (stream.destroyed) { | ||
return | ||
} | ||
Atomics.store(stream[kImpl].state, READ_INDEX, 0) | ||
@@ -259,3 +264,6 @@ Atomics.store(stream[kImpl].state, WRITE_INDEX, 0) | ||
if (this[kImpl].destroyed) { | ||
throw new Error('the worker has exited') | ||
if (typeof cb === 'function') { | ||
process.nextTick(cb, new Error('the worker has exited')) | ||
} | ||
return | ||
} | ||
@@ -262,0 +270,0 @@ |
{ | ||
"name": "thread-stream", | ||
"version": "0.13.2", | ||
"version": "0.14.0", | ||
"description": "A streaming way to send data to a Node.js Worker Thread", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"standard": "^16.0.3", | ||
"tap": "^15.0.0", | ||
"tap": "^16.0.0", | ||
"why-is-node-running": "^2.2.0" | ||
@@ -18,0 +18,0 @@ }, |
@@ -249,1 +249,24 @@ 'use strict' | ||
}) | ||
test('destroy does not error', function (t) { | ||
t.plan(3) | ||
const dest = file() | ||
const stream = new ThreadStream({ | ||
filename: join(__dirname, 'to-file.js'), | ||
workerData: { dest }, | ||
sync: false | ||
}) | ||
stream.on('ready', () => { | ||
t.pass('ready emitted') | ||
stream.worker.terminate() | ||
}) | ||
stream.on('error', (err) => { | ||
t.equal(err.message, 'The worker thread exited') | ||
stream.flush((err) => { | ||
t.equal(err.message, 'the worker has exited') | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
50226
1541