Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Collapse/Coalese multiple async calls into one to reduce load and bottle necks in an application
provides a helper function that allows the grouping\coalesing of async function calls that have cachable output. This provides more resiliance around cachable code paths that have not been cached yet.
if you had a route that took 20 seconds to resolve the first time, but was cachable if 1000 users hit that route before it had a chance to resolve it would result in an attempt to resolve that route 1000 times.
collapsio will limit the number of times that route can be executed concurrently and hold the other request until it has been resolved and then passes those results onto the 1000 requests.
var collapse = require('./collapsio');
collapse({}, 'key-http://google.com', request.get.bind(null, 'http://google.com'), function callback(req, res) {
});
collapse(
)
Without a cache this would never complete.
var collapse = require('./collapsio'),
request = require('request'),
url = 'http://google.com',
start = new Date(),
requestCount = 100000,
requestCompleted = 0;
for (var i = 0; i < requestCount; i++) {
request.get(url, function(req, res) {
requestCompleted++;
if (requestCompleted === requestCount) console.log("Completed in:", new Date() - start + "ms");
});
}
With a cache a large number of requests will be created in the time it takes for the first one to return and populate the cache, and in many cases prevent the first request from actually returning.
var collapse = require('./collapsio'),
request = require('request'),
url = 'http://google.com',
start = new Date(),
requestCount = 100000,
requestCompleted = 0,
cachedResponse = null;
for (var i = 0; i < requestCount; i++) {
if(!cachedResponse){
request.get(url, function(req, res) {
cachedResponse = arguments;
requestCompleted++;
if (requestCompleted === requestCount) console.log("Completed in:", new Date() - start + "ms");
});
} else {
requestCompleted++;
if (requestCompleted === requestCount) console.log("Completed in:", new Date() - start + "ms");
}
}
With collapsio a significantly lower number of requests are made and the result of the first successful request are passed to all of the attempts.
var collapse = require('./collapsio'),
request = require('request'),
url = 'http://google.com',
start = new Date(),
requestCount = 100000,
requestCompleted = 0;
for (var i = 0; i < requestCount; i++) {
collapse({}, url, request.get.bind(null, url), function(req, res) {
requestCompleted++;
if (requestCompleted === requestCount) console.log("Completed in:", new Date() - start + "ms");
});
}
FAQs
Collapse/Coalese multiple async calls into one to reduce load and bottle necks in an application
We found that collapsio 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.