Gathering detailed insights and metrics for @runnable/cls-bluebird
Gathering detailed insights and metrics for @runnable/cls-bluebird
Gathering detailed insights and metrics for @runnable/cls-bluebird
Gathering detailed insights and metrics for @runnable/cls-bluebird
npm install @runnable/cls-bluebird
Typescript
Module System
Node Version
NPM Version
72.6
Supply Chain
98
Quality
74.7
Maintenance
100
Vulnerability
100
License
JavaScript (99.7%)
Shell (0.3%)
Total Downloads
16,544
Last Day
2
Last Week
2
Last Month
18
Last Year
172
45 Stars
38 Commits
12 Forks
4 Watchers
1 Branches
3 Contributors
Updated on Apr 04, 2024
Minified
Minified + Gzipped
Latest Version
1.1.3
Package Id
@runnable/cls-bluebird@1.1.3
Size
5.97 kB
NPM Version
2.14.7
Node Version
4.2.2
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
0%
2
Compared to previous week
Last Month
12.5%
18
Compared to previous month
Last Year
59.3%
172
Compared to previous year
Patch bluebird for continuation-local-storage support.
Compatible with bluebird v2.x and v3.x. Tests cover both versions.
clsBluebird( ns [, Promise] )
1var cls = require('continuation-local-storage'); 2var ns = cls.createNamespace('myNamespace'); 3 4var Promise = require('bluebird'); 5var clsBluebird = require('cls-bluebird'); 6 7clsBluebird( ns ); 8// Promise is now patched to maintain CLS context
The above patches the "global" instance of bluebird. So anywhere else in the same app that calls require('bluebird')
will get the patched version (assuming npm resolves to the same file).
To patch a particular instance of bluebird:
1var Promise = require('bluebird'); 2var clsBluebird = require('cls-bluebird'); 3 4clsBluebird( ns, Promise );
This is a more robust approach.
Combining CLS and promises is a slightly tricky business. There are 3 different conventions one could use (see this issue for more detail).
cls-bluebird
follows the convention of binding .then()
callbacks to the context in which .then()
is called.
1var promise; 2ns.run(function() { 3 ns.set('foo', 123); 4 promise = Promise.resolve(); 5}); 6 7ns.run(function() { 8 ns.set('foo', 456); 9 promise.then(print); 10}); 11 12function print() { 13 console.log(ns.get('foo')); 14} 15 16// this outputs '456' (the value of `foo` at the time `.then()` was called)
Promise.onPossiblyUnhandledRejection()
and Promise.onUnhandledRejectionHandled()
allow you to attach global handlers to intercept unhandled rejections.
The CLS context in which callbacks are called is unknown. It's probably unwise to rely on the CLS context in the callback being that when the rejection occurred - use .catch()
on the end of the promise chain that's created within namespace.run()
instead.
Use npm test
to run the tests. Use npm run cover
to check coverage.
See changelog.md
If you discover a bug, please raise an issue on Github. https://github.com/TimBeyer/cls-bluebird/issues
Pull requests are very welcome. Please:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More