odavid / typeorm-transactional-cls-hooked

A Transactional Method Decorator for typeorm that uses cls-hooked to handle and propagate transactions between different repositories and service methods. Inpired by Spring Trasnactional Annotation and Sequelize CLS
MIT License
522 stars 86 forks source link

No context available. ns.run() or ns.bind() must be called first #48

Closed riichg5 closed 4 years ago

riichg5 commented 4 years ago

{ "status": 500, "errstr": "No context available. ns.run() or ns.bind() must be called first.", "data": "{\"errorMsg\":\"No context available. ns.run() or ns.bind() must be called first.\",\"stack\":\"Error: No context available. ns.run() or ns.bind() must be called first. at Namespace.set (/xxx/node_modules/cls-hooked/context.js:36:11) at Object.exports.setEntityManagerForConnection (/xxx/node_modules/typeorm-transactional-cls-hooked/src/common.ts:40:14) at Task.<anonymous> (/xxx/node_modules/typeorm-transactional-cls-hooked/src/Transactional.ts:46:11) at step (/xxx/node_modules/typeorm-transactional-cls-hooked/dist/Transactional.js:32:23) at Object.next (/xxx/node_modules/typeorm-transactional-cls-hooked/dist/Transactional.js:13:53) at /xxx/node_modules/typeorm-transactional-cls-hooked/dist/Transactional.js:7:71 at Promise._execute (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/debuggability.js:272:9) at Promise._resolveFromExecutor (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/promise.js:473:18) at new Promise (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/promise.js:77:14) at __awaiter (/xxx/node_modules/typeorm-transactional-cls-hooked/dist/Transactional.js:3:12) at transactionCallback (/xxx/node_modules/typeorm-transactional-cls-hooked/src/Transactional.ts:45:72) at EntityManager.<anonymous> (/xxx/src/entity-manager/EntityManager.ts:138:34) at step (/xxx/node_modules/tslib/tslib.js:133:27) at Object.next (/xxx/node_modules/tslib/tslib.js:114:57) at fulfilled (/xxx/node_modules/tslib/tslib.js:104:62) at tryCatcher (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/promise.js:502:31) at Promise._settlePromise (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/promise.js:559:18) at Promise._settlePromise0 (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/promise.js:604:10) at Promise._settlePromises (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/promise.js:683:18) at Async._drainQueue (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/async.js:138:16) at Async._drainQueues (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/async.js:148:10) at Immediate.Async.drainQueues [as _onImmediate] (/xxx/node_modules/thinkjs/node_modules/bluebird/js/release/async.js:17:14) at processImmediate (timers.js:637:19)\"}" }

Is there someone can help me?

odavid commented 4 years ago

Hello, Seems you did not initialize the context See https://github.com/odavid/typeorm-transactional-cls-hooked/blob/master/README.md#initialization