sails: Sails request hangs on sails.getDataStore().transaction(fn) , and fn seems not executed when sails-mysql upgraded to 1.0.0-16

Sails version: 1.0.0-37 Node version: 6.10.0 ,8.9.3 NPM version: 3.10.10, 5.5.1 DB adapter name: sails-mysql DB adapter version: 1.0.0-16 Operating system: Linux (Amazon Linux AMI), MacOS 10.13.1


Hi, 5 days ago (on 23/12/17) suddenly I notice that my datastore transaction is not working and from the logs of my server, I saw that when there is a request, the processing hangs on sails.getDataStore().transaction(fn) and it seems the fn was not getting executed. I’m using sails v1.0 and I’ve tried in both node 6.10.0 LTS and 8.9.3 LTS and the issue persists.

Then later I found out that the sails-mysql is updated to 1.0.0-16 , 7 days ago (on 21/12/7) from sails-mysql git repo and since sails js framework setting on sails-mysql : ^1.0.0-14, hence it updated to 1.0.0-16 when i reinstall (npm install) and rebuild the package. The issue was not happening on sails-mysql 1.0.0-15.

How I’m using the data store transaction is as follows, (which I guess from the previous example from sails documentation),

 sails.getDatastore().transaction(function (db, proceed) {
      async.waterfall([
        function(done) {
           // do something
           return done(null);
        }
      ], function(err) {
        if (err) {
           return proceed(err); 
        }
        return proceed(); 
        
      });
    
 }).exec(function(err){
   return res.ok()
});

Which I notice that the example on the implementation has been changed here https://next.sailsjs.com/documentation/reference/waterline-orm/datastores/transaction.

I tried to use ‘await’ but it always throws syntax error : Unexpected identifier. My current implementation is fine with sails-mysql version 1.0.0-15, so does the issue is because the way the transaction function need to be defined with async (if want to use v 1.0.0-16) like in the current example on sails documentation or my current implementation is fine but there are some steps i have missed here?

Thanks a lot in advance for any help/assistance provided.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 20 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I’m also getting hanging request issues, but with Model.getDatastore().sendNativeQuery(). I’m using sails-mysql 1.0.0-16 as well.

@guretno @sgress454 @fenichelar @itomas @smihaljenovic @moty66 @akraminakib @mokxter @TomislavStrugacevac Hey everyone, thanks for the help. I just published a release of sails-hook-orm (2.0.0-23) with a fix. To pick that up, run npm install sails-hook-orm@^2.0.0-23 in your project (or if you prefer to pin your semver ranges, do npm install sails-hook-orm@2.0.0-23 --save-exact).

Here’s what happened: First of all, this bug was particularly pernicious because machine wasn’t properly informing us that something was amiss (it wasn’t throwing this error like it should have been). So I went ahead and corrected that and published as machine@15.0.0-22.

Now for the actual bug: For compatibility, sails-hook-orm calls the driver directly rather than using the adapter within its implementation of the RDI methods-- that is, the datastore methods available in userland (sendNativeQuery(), transaction(), etc). But when I bumped the runner version in the mp-mysql driver, I didn’t update the usage in sh-orm. That’s fixed now.

@guretno @sgress454 @fenichelar @itomas @smihaljenovic @moty66 @akraminakib @mokxter @TomislavStrugacevac I verified that this patch fixes the repro here, but when y’all have a moment, would you try that out and make sure everything looks good in your apps?

@mikermcneil confirmed fix here as well. @ultamatt I second the rm -rf node_modules && npm install!

@mikermcneil , Yes it is fine now, the transaction callback is called. perfect, Thanks! I changed the sails-hook-orm to 2.0.0-23 and sails-mysql to 1.0.0-17. I see the machine also has been upgraded to machine@15.0.0-22.

    "sails": "^1.0.0-37",
    "sails-disk": "~0.10.0",
    "sails-hook-grunt": "^2.0.0",
    "sails-hook-orm": "2.0.0-23",
    "sails-hook-sockets": "^1.4.0",
    "sails-mysql": "1.0.0-17",

@ultamatt , I guess you can try to remove the sails node_modules folder and try to npm install again, as some dependencies e.g machines in sails-mysql@1.0.0-17 has been updated as well.

I also have the same issue with Model.getDatastore().sendNativeQuery(). Downgrading sails-mysql to 1.0.0-15 resolved the issue.

Yes, for us, downgrading sails-mysql to 1.0.0-15 helped to solve this issue.

@moty66 try to remove node_modules, clear cache and etc… 15v should fix.