
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
when-connected
Advanced tools
call an async method with configurable timeout and when connected if reconnect is used
perform a callback when "connected" or fire callback with timeout error if its taken too long.
the most important thing this does is provides you with the errors required to manage callback and stream disconnection in necessary ways.
this lib is generic and ensures that wrapped calls are only made when connected. these examples use multilevel a package used to interact with leveldb over the network but it is not the only reason this is useful.
var mulitlevel = require('multilevel');
var reconnect = require('reconnect');
var whenConnected = require('when-connected')
var client;
var recon = reconnect(function(stream){
client = multilevel.client();
stream.pipe(client).pipe(stream);
}).connect(PORT);
var get = whenConnected(function(key,cb){
client.get(key,cb);
},{reconnect:recon});
var dumpDB = whenConnected(function(){
return client.createReadStream();
},{reconnect:recon,stream:true});
// get a key.
get('a',function(err,data){
console.log('get called back');
});
var dump = dumpDB();
// output a db dump.
dump.on('data',function(data){
console.log('db: ',data);
});
this exports one function.
whenConnected([the function to call when connected],[options])
error objects returned by this lib all have a code proerty that is one of these values. they are either emitted as errors onn streams or passed as the error to a callback.
FAQs
call an async method with configurable timeout and when connected if reconnect is used
We found that when-connected 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.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.