Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@ms-cloudpack/worker-pool
Advanced tools
Provides utilities for simplifying worker execution.
There are two source files when using workers - the worker entry, which hosts the code to be executed within the worker, and the host source, which instantiates the pool and executes the work.
For worker reuse to work properly, the method(s) being run must not have any async/scheduled code which continues running after the result is returned. Otherwise, if the scheduled code causes an error after the method returns, the error will either be swallowed (if no method was running in the worker at the time) or associated with the wrong method call (if another method call has been started).
If running arbitrary external code in a worker, it's recommended to overwrite all methods for async scheduling (setTimeout
etc) with no-op versions.
Also be mindful of any cleanup of global state which might need to happen in between runs. This can be done with afterEach
(see below).
First, let's set up the worker entry that will execute work inside the worker. Use initializeWorker
to set up your api surface:
workerEntry.ts
:
import { initializeWorker } from '@ms-cloudpack/worker-pool';
import { methodA, methodB } from './methods';
// Load any environmental side effects here.
// Then initialize the worker with the appropriate listeners and api dictionary.
initializeWorker({
beforeEach: () => {...}, // optional
afterEach: () => {...}, // optional
methods: {
methodA,
methodB,
},
});
In the host where we want to execute things to asynchronously run in the pool of workers:
import { WorkerPool } from '@ms-cloudpack/worker-pool';
const pool = new WorkerPool({ entry: './workerEntry.js' });
Work is executed from the pool created above:
const result = await pool.execute('methodA', [arg1, arg2, etc]);
FAQs
General worker pool helper.
We found that @ms-cloudpack/worker-pool demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.