Patches Bluebird promises to work with continuation-local-storage (CLS), enabling automatic propagation of CLS context across promise chains. Version 2.1.0 is a complete rewrite aiming for full reliability with over 100,000 tests. Compatible with Bluebird v2.x and v3.x. The patching follows the convention of binding .then() callbacks to the context in which .then() is called. Supports coroutines, Promise.map, Promise.reduce, and other Bluebird methods. Maintained but limited to legacy CLS module (not async_hooks). For async_hooks-based CLS (e.g., cls-hooked), use alternative patches.
npm install cls-bluebirdNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a CLS namespace, patching a Bluebird copy, and verifying context propagation across promise .then() callbacks.
Consider using cls-hooked with a different promise patch (e.g., cls-bluebird-hooked).
Always use getNewLibraryCopy() and pass the instance to avoid global side effects.
Use clsBluebird(ns) or clsBluebird(ns, Promise) as the new API.
Upgrade to 2.1.0 which improved coverage. If still broken, test with bluebird v3.
Ensure you are using a supported bluebird version (2.x or 3.x) and test extensively.
Use const clsBluebird = require('cls-bluebird'); (CommonJS). Do NOT use import clsBluebird from 'cls-bluebird'.Provide a CLS namespace: clsBluebird(ns [, Promise]);
Create a namespace via cls.createNamespace('name') and pass it.