thread-stream
Advanced tools
Comparing version 0.11.1 to 0.11.2
16
index.js
@@ -12,3 +12,7 @@ 'use strict' | ||
} = require('./lib/indexes') | ||
const buffer = require('buffer') | ||
// V8 limit for string size | ||
const MAX_STRING = buffer.constants.MAX_STRING_LENGTH | ||
class FakeWeakRef { | ||
@@ -32,2 +36,5 @@ constructor (value) { | ||
const registry = new FinalizationRegistry((worker) => { | ||
if (worker.exited) { | ||
return | ||
} | ||
worker.terminate() | ||
@@ -127,2 +134,3 @@ }) | ||
if (stream === undefined) { | ||
this.exited = true | ||
// Terminate the worker. | ||
@@ -154,2 +162,3 @@ this.terminate() | ||
stream.closed = true | ||
stream.worker.exited = true | ||
// TODO only remove our own | ||
@@ -175,2 +184,3 @@ stream.worker.removeAllListeners('exit') | ||
stream.closed = true | ||
stream.worker.exited = true | ||
setImmediate(function () { | ||
@@ -227,2 +237,8 @@ if (code !== 0) { | ||
if (this.flushing && this.buf.length + data.length >= MAX_STRING) { | ||
// process._rawDebug('write: flushing') | ||
this._writeSync() | ||
this.flushing = true // we are still flushing | ||
} | ||
if (!this.ready || this.flushing) { | ||
@@ -229,0 +245,0 @@ this.buf += data |
{ | ||
"name": "thread-stream", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "A streaming way to send data to a Node.js Worker Thread", | ||
@@ -12,6 +12,7 @@ "main": "index.js", | ||
"standard": "^16.0.3", | ||
"tap": "^15.0.0" | ||
"tap": "^15.0.0", | ||
"why-is-node-running": "^2.2.0" | ||
}, | ||
"scripts": { | ||
"test": "standard && tap --no-check-coverage test/*.test.*js", | ||
"test": "standard && tap test/*.test.*js", | ||
"test:ci": "standard && tap \"test/**/*.test.*js\" --no-check-coverage --coverage-report=lcovonly", | ||
@@ -18,0 +19,0 @@ "test:yarn": "tap \"test/**/*.test.js\" --no-check-coverage", |
@@ -6,2 +6,4 @@ 'use strict' | ||
const { unlinkSync } = require('fs') | ||
const why = require('why-is-node-running') | ||
const t = require('tap') | ||
@@ -12,3 +14,3 @@ const files = [] | ||
function file () { | ||
const file = join(tmpdir(), `thread-stream-${process.pid}-${process.hrtime().toString()}-${count++}`) | ||
const file = join(tmpdir(), `thread-stream-${process.pid}-${count++}`) | ||
files.push(file) | ||
@@ -19,4 +21,6 @@ return file | ||
process.on('beforeExit', () => { | ||
t.comment('unlink files') | ||
for (const file of files) { | ||
try { | ||
t.comment(`unliking ${file}`) | ||
unlinkSync(file) | ||
@@ -27,4 +31,7 @@ } catch (e) { | ||
} | ||
t.comment('unlink completed') | ||
}) | ||
module.exports.file = file | ||
setInterval(why, 10000).unref() |
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
45991
34
1436
7
13