Transactions causing - Warning: a promise was created in a handler but was not returned from it

681 views
Skip to first unread message

Yuval Kaplan

unread,
Jan 4, 2016, 12:28:33 PM1/4/16
to Sequelize
Hi,

I have the following code:


return sequelize.transaction(function (t) {
   
return new Promise(function(resolve, reject) {
     
return resolve("OK");
   
});
})
.then(function(result) {
   console
.log(result);
})
.catch(function(err) {
   console
.log(err);
});


I get the following warning:


Warning: a promise was created in a handler but was not returned from it
    at ConnectionManager.releaseConnection (/home/yuval/myapp/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:253:10)
    at Transaction.cleanup (/home/yuval/myapp/node_modules/sequelize/lib/transaction.js:278:46)
    at /home/yuval/myapp/node_modules/sequelize/lib/transaction.js:188:14
From previous event:
    at Promise.finally (/home/yuval/myapp/node_modules/sequelize/lib/promise.js:21:17)
    at Transaction.commit (/home/yuval/myapp/node_modules/sequelize/lib/transaction.js:185:13)
    at /home/yuval/myapp/node_modules/sequelize/lib/sequelize.js:1237:30
From previous event:
    at Promise.then (/home/yuval/myapp/node_modules/sequelize/lib/promise.js:21:17)
    at Sequelize.transaction.transactionResolver (/home/yuval/myapp/node_modules/sequelize/lib/sequelize.js:1228:40)
From previous event:
    at Sequelize.transaction (/home/yuval/myapp/node_modules/sequelize/lib/sequelize.js:1257:12)
    at self.testOrm (/home/yuval/myapp/source/main.js:186:30)
    at /home/yuval/myapp/source/main.js:232:17
    at processImmediate [as _immediateCallback] (timers.js:374:17)
From previous event:
    at Promise.then (/home/yuval/myapp/node_modules/sequelize/lib/promise.js:21:17)
    at self.setupAndStart (/home/yuval/myapp/source/main.js:231:5)
    at /home/yuval/myapp/server.js:11:7
    at Object.context.execCb (/home/yuval/myapp/node_modules/requirejs/bin/r.js:1929:33)
    at Object.Module.check (/home/yuval/myapp/node_modules/requirejs/bin/r.js:1129:51)
    at Object.Module.enable (/home/yuval/myapp/node_modules/requirejs/bin/r.js:1416:22)
    at Object.Module.init (/home/yuval/myapp/node_modules/requirejs/bin/r.js:1034:26)
    at null._onTimeout (/home/yuval/myapp/node_modules/requirejs/bin/r.js:1692:36)
    at Timer.listOnTimeout (timers.js:89:15)



With Sequelize logging turned on I get the following log output before I get the above warning:


Executing
(d60ae591-6d3a-47a0-aae9-b54db4b2e172): START TRANSACTION;
Executing (d60ae591-6d3a-47a0-aae9-b54db4b2e172): SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Executing (d60ae591-6d3a-47a0-aae9-b54db4b2e172): SET autocommit = 1;
Executing (d60ae591-6d3a-47a0-aae9-b54db4b2e172): COMMIT;


I think this is as basic as it gets and the transaction seems to be working correctly so I am not sure what I am doing wrong.

If I run a simple Promise or any other Sequelize call (find, update, create) without the transaction it does not show this warning.

It would be really helpful if anyone can spot what I am doing wrong. 

Thanks!

Yuval Kaplan

unread,
Jan 4, 2016, 12:40:46 PM1/4/16
to Sequelize
Just to makes things a little bit more readable. If I place the code section after I create the sequelize instance and then run the code, I get the following warning:


Warning: a promise was created in a handler but was not returned from it                                                                                                                                                              
    at
ConnectionManager.releaseConnection (/home/yuval/myapp/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:253:10)                                                                                            
    at
Transaction.cleanup (/home/yuval/myapp/node_modules/sequelize/lib/transaction.js:278:46)                                                                                                                                      
    at
/home/yuval/myapp/node_modules/sequelize/lib/transaction.js:188:14
                                                                                                                                                           
    at processImmediate
[as _immediateCallback] (timers.js:374:17)                                                                                                                                                                          
From previous event:                                                                                                                                                                                                                        
    at
Promise.finally (/home/yuval/myapp/node_modules/sequelize/lib/promise.js:21:17)                                                                                                                                              
    at
Transaction.commit (/home/yuval/myapp/node_modules/sequelize/lib/transaction.js:185:13)                                                                                                                                      
    at
/home/yuval/myapp/node_modules/sequelize/lib/sequelize.js:1237:30


All the rest is the same.

Mick Hansen

unread,
Jan 5, 2016, 2:47:06 AM1/5/16
to Yuval Kaplan, Sequelize
Known issue after we upgraded Bluebird, trying to find out where its originating.
--
Mick Hansen
@mhansendev
mhansen.io

Yuval Kaplan

unread,
Jan 5, 2016, 4:08:04 AM1/5/16
to Sequelize, yuva...@gmail.com
Thanks Mick.

Any open issue I can follow to get an update on when this gets fixed?

Mick Hansen

unread,
Jan 5, 2016, 4:15:23 AM1/5/16
to Yuval Kaplan, Sequelize
There's an issue on github somewhere, but it's sort of an ongoing process since we're not totally sure where it's happening.

Bondi French

unread,
Mar 17, 2016, 6:23:23 PM3/17/16
to Sequelize, yuva...@gmail.com
I have the same error with MS SQL and Sequelize 3.19.3, here is the error I got:

Warning: a promise was created in a handler but was not returned from it                                                 
    at processImmediate [as _immediateCallback] (timers.js:383:17)                                                       
From previous event:                                                                                                     
    at Model.findAll (c:\Users\London\Apps\FinviewsApp\node_modules\Sequelize\lib\model.js:1343:18)                      
    at c:\Users\London\Apps\FinviewsApp\routes\api.js:486:16                                                             
    at Layer.handle [as handle_request] (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\layer.js:76:5) 
    at next (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\route.js:100:13)                           
    at Route.dispatch (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\route.js:81:3)                   
    at Layer.handle [as handle_request] (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\layer.js:76:5) 
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:234:24                                  
    at Function.proto.process_params (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:312:12)  
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:228:12                                  
    at Function.match_layer (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:295:3)            
    at next (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:189:10)                           
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:191:16                                  
    at Function.match_layer (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:295:3)            
    at next (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:189:10)                           
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:191:16                                  
    at Function.match_layer (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:295:3)            
    at next (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:189:10)                           
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:191:16                                  
From previous event:                                                                                                     
    at Promise.then (c:\Users\London\Apps\FinviewsApp\node_modules\Sequelize\lib\promise.js:21:17)                       
    at c:\Users\London\Apps\FinviewsApp\config\passport.js:21:5                                                          
    at pass (c:\Users\London\Apps\FinviewsApp\node_modules\passport\lib\authenticator.js:353:9)                          
    at Authenticator.deserializeUser (c:\Users\London\Apps\FinviewsApp\node_modules\passport\lib\authenticator.js:358:5) 
    at SessionStrategy.authenticate (c:\Users\London\Apps\FinviewsApp\node_modules\passport\lib\strategies\session.js:49:
    at attempt (c:\Users\London\Apps\FinviewsApp\node_modules\passport\lib\middleware\authenticate.js:341:16)            
    at authenticate (c:\Users\London\Apps\FinviewsApp\node_modules\passport\lib\middleware\authenticate.js:342:7)        
    at Layer.handle [as handle_request] (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\layer.js:76:5) 
    at trim_prefix (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:270:13)                    
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:237:9                                   
    at Function.proto.process_params (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:312:12)  
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:228:12                                  
    at Function.match_layer (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:295:3)            
    at next (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:189:10)                           
    at initialize (c:\Users\London\Apps\FinviewsApp\node_modules\passport\lib\middleware\initialize.js:62:5)             
    at Layer.handle [as handle_request] (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\layer.js:76:5) 
    at trim_prefix (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:270:13)                    
    at c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:237:9                                   
    at Function.proto.process_params (c:\Users\London\Apps\FinviewsApp\node_modules\express\lib\router\index.js:312:12)  

Mick Hansen

unread,
Mar 18, 2016, 5:13:35 AM3/18/16
to Bondi French, Sequelize, Yuval Kaplan
Reply all
Reply to author
Forward
0 new messages