A shim that patches Q promises to preserve continuation-local storage (CLS) contexts when calling promise.then(). Specifically designed to fix interoperability issues between Q and modules like node-redis that perform non-standard async operations. Current version 1.1.0 (last release). Works by binding callbacks to ensure the active CLS namespace is propagated. Supports binding to multiple namespaces, but with performance overhead. Requires peer dependencies `continuation-local-storage` ~3.x and `q` >=0.9.7. Lightweight (~50 lines) but only suitable for legacy Q-based codebases; modern users should migrate to native promises or async/await.
npm install cls-qNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a CLS namespace, patches Q, and demonstrates preserved context inside a promise callback.
Migrate to native promises (ES2015+) or async/await; use AsyncLocalStorage (Node 12+) for context propagation.
Minimize the number of namespaces or use a single namespace with prefix keys.
Manual context binding may be needed for other promise chain methods.
Upgrade Q to >=0.9.7 or use a compatible version of cls-q (older releases).
Install from GitHub: `npm install othiym23/cls-q`.
Use `const patchQ = require('cls-q');`Ensure `patchQ(ns)` is called before any Q promise is created, and that the same namespace is used in `run()` and `get()`.