Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
advqueue
Advanced tools
Readme
Queue controlling for Promises
npm i advqueue
const AdvQueue = require('advqueue')
// or
import AdvQueue from 'advqueue'
const queue = new AdvQueue()
/**
* How long a promise should stay on queue before timing out (default is Infinity)
* @type Number
*/
queue.queuedTimeout = Infinity
/**
* How long a queued promise should stay under processing (without resolving) before timing out (default is Infinity)
* @type Number
*/
queue.processingTimeout = Infinity
/**
* How many promises should be concurrently executed
* @type {Number}
*/
queue.concurrency = 1
/**
* Callback for when a promise does not process within the queuedTimeout
* @type Function
*/
onQueuedTimeout = ({ id, name, priority, resolve, reject, createdAt, fn, rawFn }) => {
// perhaps you could reject the promise so queue.add won't await forever?
reject("wtf")
}
/**
* Callback for when a promise does not resolve within the processingTimeout
* @type Function
*/
onProcessingTimeout = ({ id, name, priority, resolve, reject, createdAt, fn, rawFn, startedAt }) => {
// or how about retrying?
resolve(queue.add(rawFn, priority, name))
// or perhaps you want to wait 5 seconds then retry?
setTimeout(() => resolve(queue.add(rawFn, priority, name)), 5000)
}
The callback gets called with an object with the following properties:
queue.add(() => {
return new Promise((resolve, reject) => {
setTimeout(() => resolve('hey from async'), 3000)
})
}).then(result => {
console.log(result) // 'hey from async' after 3s
})
// you may also add synchronous functions
queue.add(() => {
return 'hey from sync'
}).then(result => {
console.log(result)
})
In the example above, since the concurrency is set to 1, the first promise will run and generate 'hey from async' after 3s, and only then the synchronous function will run and generate 'hey from sync'.
Arguments for queue.add
:
FAQs
Local queue management
We found that advqueue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.