-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async controller fails to bind to routes #3863
Comments
Hi @adnan-kamili! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check. Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly. If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@treeline.io. |
ok fixed |
Sails uses async as dependency. Perhaps this causes your error? |
Check the updated issue perhaps it is a bug in underscore lib |
To fix the issue I made following change in the sails core - sails/lib/hooks/controllers/to-interpret-route-syntax.js:
But routes are still not binding |
Hey @adnan-kamili, out of curiosity, why do you need to be able to write |
Making the controller function async makes it possible to await the Promises inside the controller. So I can avoid callbacks and promise then chains:
instead of
|
@karsasmus good thinking btw -- could easily be related (cc @megawac) @adnan-kamili ah gotcha-- I didn't realize this was limited to functions marked with the |
@karsasmus ohhh nevermind, apologies. (@megawac, sorry to bother you) It's lodash/lodash#2768 |
@karsasmus @adnan-kamili Posted here: lodash/lodash#2768 (comment) @sailsbot including you too, just for the moral support |
@mikermcneil The bug replicates for arrow functions too in controller even without using async keyword. |
For anyone looking for a safe hotfix until a fix lands in the sails.js (most probably requiring a fork of lodash@3) you can override the lodash object in following file: sails/lib/hooks/controllers/to-interpret-route-syntax.js
|
@adnan-kamili gotcha, thanks
Thanks for posting that! I'll push out a fix for this on 0.12.x asap.
|
@adnan-kamili ok I've got this working locally with a Lodash 3.10.2 patch on a branch-- waiting to hear back from someone and then will post back here to ask you to confirm. Thanks again for the help! |
@mikermcneil Waiting for the fix |
@agnan-kamili k it's on master (lodash/lodash#2768 (comment)) |
@mikermcneil master seems to be at v1.0.10. Can you do an release on 0.12.x_rc so that I can check it out. |
@mikermcneil when can we expect the fix to land in 0.12.x branch |
@adnan-kamili Thanks for the reminder! Backporting this isn't at the top of my list right now tbh, since it's not affecting documented usage or existing code in 0.12 apps-- although I am 100% down to backport support for node 7 async functions to a Sails 0.12 release ASAP! I'll just need someone to help test it out on master first. |
@mikermcneil I have tested it with sails v1.0.0-11 and it is working fine.
|
@adnan-kamili thank you! I'll backport this for v0.12 today |
@adnan-kamili just published under the "0.12-pre" tag: npm install sails@^0.12.11-0 --force It's working for me in the example app from the book, but just as a final verification, would you give that a go and give me the thumbs up if it works for you? Then I'll go ahead and publish 0.12.11 (in the mean time, you can change your package.json to |
I tested it and it works fine :) Thanks for backporting it. |
@adnan-kamili thank you! Bundling one other bug fix and publishing as 0.12.11 today, hopefully. In the mean time, your semver range should continue to work indefinitely 👍 |
@adnan-kamili Just a heads up: This is now published as latest (0.12.11). |
@mikermcneil Thanks :) |
BEGIN VERSION INFO
-->
Sails version: 0.12.7
Node version: 7.0.0
NPM version: 3.10.8
Operating system: macOS Sierra
The text was updated successfully, but these errors were encountered: