Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

piscina

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piscina - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

2

dist/package.json
{
"name": "piscina",
"version": "1.6.0",
"version": "1.6.1",
"description": "A fast, efficient Node.js Worker Thread Pool implementation",

@@ -5,0 +5,0 @@ "main": "./dist/src/index.js",

@@ -5,7 +5,11 @@ /// <reference types="node" />

import { Transferable, TaskQueue } from './common';
interface AbortSignalEventTargetAddOptions {
once: boolean;
}
interface AbortSignalEventTarget {
addEventListener: (name: 'abort', listener: () => void) => void;
addEventListener: (name: 'abort', listener: () => void, options?: AbortSignalEventTargetAddOptions) => void;
aborted?: boolean;
}
interface AbortSignalEventEmitter {
on: (name: 'abort', listener: () => void) => void;
once: (name: 'abort', listener: () => void) => void;
}

@@ -12,0 +16,0 @@ declare type AbortSignalAny = AbortSignalEventTarget | AbortSignalEventEmitter;

@@ -42,8 +42,9 @@ "use strict";

})();
;
function onabort(abortSignal, listener) {
if ('addEventListener' in abortSignal) {
abortSignal.addEventListener('abort', listener);
abortSignal.addEventListener('abort', listener, { once: true });
}
else {
abortSignal.on('abort', listener);
abortSignal.once('abort', listener);
}

@@ -531,2 +532,7 @@ }

if (abortSignal !== null) {
// If the AbortSignal has an aborted property and it's truthy,
// reject immediately.
if (abortSignal.aborted) {
return Promise.reject(new AbortError());
}
onabort(abortSignal, () => {

@@ -533,0 +539,0 @@ // Call reject() first to make sure we always reject with the AbortError

{
"name": "piscina",
"version": "1.6.0",
"version": "1.6.1",
"description": "A fast, efficient Node.js Worker Thread Pool implementation",

@@ -5,0 +5,0 @@ "main": "./dist/src/index.js",

@@ -697,2 +697,7 @@ # piscina - the node.js worker pool

### 1.6.1
* Bug fix: Reject if AbortSignal is already aborted
* Bug Fix: Use once listener for abort event
### 1.6.0

@@ -699,0 +704,0 @@

@@ -44,7 +44,15 @@ import { Worker, MessageChannel, MessagePort, receiveMessageOnPort } from 'worker_threads';

interface AbortSignalEventTargetAddOptions {
once : boolean;
};
interface AbortSignalEventTarget {
addEventListener : (name : 'abort', listener : () => void) => void;
addEventListener : (
name : 'abort',
listener : () => void,
options? : AbortSignalEventTargetAddOptions) => void;
aborted? : boolean;
}
interface AbortSignalEventEmitter {
on : (name : 'abort', listener : () => void) => void;
once : (name : 'abort', listener : () => void) => void;
}

@@ -54,5 +62,5 @@ type AbortSignalAny = AbortSignalEventTarget | AbortSignalEventEmitter;

if ('addEventListener' in abortSignal) {
abortSignal.addEventListener('abort', listener);
abortSignal.addEventListener('abort', listener, { once: true });
} else {
abortSignal.on('abort', listener);
abortSignal.once('abort', listener);
}

@@ -705,2 +713,7 @@ }

if (abortSignal !== null) {
// If the AbortSignal has an aborted property and it's truthy,
// reject immediately.
if ((abortSignal as AbortSignalEventTarget).aborted) {
return Promise.reject(new AbortError());
}
onabort(abortSignal, () => {

@@ -707,0 +720,0 @@ // Call reject() first to make sure we always reject with the AbortError

@@ -148,1 +148,19 @@ import { AbortController } from 'abort-controller';

});
test('aborted AbortSignal rejects task immediately', async ({ rejects, is }) => {
const pool = new Piscina({
filename: resolve(__dirname, 'fixtures/move.ts')
});
const controller = new AbortController();
// Abort the controller early
controller.abort();
is(controller.signal.aborted, true);
// The data won't be moved because the task will abort immediately.
const data = new Uint8Array(new SharedArrayBuffer(4));
rejects(pool.runTask(data, [data.buffer], controller.signal),
/The task has been aborted/);
is(data.length, 4);
});

Sorry, the diff of this file is not supported yet

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