Socket
Socket
Sign inDemoInstall

thread-stream

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thread-stream - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

test/unhandledRejection.js

13

lib/worker.js

@@ -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')
}
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc