-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Configure all promise returning functions as async functions #8368
Comments
Hey, Just to make sure I understand, don't modify the functions, aside from changing the method to async. However if after changing these I find problems where calling functions can't handle the now async method, I should fix these calling functions in this same PR? |
@JeremyScott-IO that'll be great go for it! And yes your understanding is perfectly correct |
Initial adding of async. NPM test all still passing. Looking to cleanup and handle async/change calling functions if required resolves:serverless#8368
If you need any more help, I would be willing to chip in. |
Hi @medikoo, I've noticed a lot of methods that return promises aren't async, and some ()=> module.exports are also returning Promises. Should I be converting methods and these module.exports to async as well? |
Ideally functions/methods which do not involve any async operations (but e.g. simply return |
@JeremyScott-IO if it appears as too large task for one PR, we may splt it. so e.g. with one PR we cover only designated folders. Let me know, I'll be more than happy to outline such roadmap if needed. Then more of us can help covering it. Great thanks again, for looking into it! |
@medikoo, I'm going to have a fair amount of time across the course of this week. I can give it a go, but I'm totally fine if you guys want to split it out and allow other contributors :) Let me know! |
@JeremyScott-IO Let's see how it goes then :) If it'll appear challenging we'll propose to seclude some areas to other PR's |
Hello Everyone. I am new to working with open source projects. I want to contribute to this project and this issue seems the right place for me to get started. I have questions regarding the folder structure. Should I also make an update inside the plugins folder? I have refactored some code inside ./lib/plugins/aws/invokeLocal/index.js to use async/await which I have attached below. Should I push it for check? Also which are the main folders that should be refactored? Thank you in Advance. |
@KishorBudhathoki10 great thanks for reaching out to help! Still this one is already being covered by @JeremyScott-IO (note the assignment). Please search other issues with good first issue label (which have no one assigned), and see if you can help with those (?) Concerning code attachments, please use compare links (e.g. you may create a branch in your fork and send us link to its compare view). Sharing zip archives doesn't feel safe |
Converted functions to async, confirmed no breakage by running npm test. Added todo notes for some functions Resolves:serverless#8368
Hi guys, I am new at open source and would like to contribute to the project, this issue looks find to get started, but please guys could you please let me know how is it going? I saw @JeremyScott-IO has started, but any update, can I help with something, how should I start working on it, please could you explain to me a little more @medikoo ... |
@Edu93Jer it appears it got stuck, and it's not surprising as this covers quite a lot. To make it easier I've split the work into multiple areas. Please see updated description. With that approach we should be able to move it effectively forward. PR's welcome! |
@Edu93Jer which part of this issue did you tackle. I have some time over the next few days and was going to clean some of this up but I don't want to step on any toes. |
Hi @ifitzsimmons I took |
can cross out |
hi @medikoo can cross out
|
hi @medikoo I believe this ticket can be closed since all folders are corrected |
Thank you @sleepwithcoffee for finalizing that, Outstanding work 👏 🎉 |
Use case description
Paves path to #7171
Ideally we should use just native promises and async/await syntax. Still refactor of whole code seems as too big and problematic task for single PR, it's better to divide it into smaller clear tasks.
As a first distinct step I believe it'll simply be good to configure all promise returning functions as async functions (with no adjustments to its bodies, the internal promise flow should remain configured as-is)
Proposed solution
Search for all functions which return an outcome of any
BbPromise*
(bluebird),Promise*
orx.then()
operation, and (1) confirm weather it's justified that function returns promise. if there are no async calls (with exception to fs sync variants which we should refactor in next step to async) (2a) Reconfigure function so it doesn't return promises. If it's otherwise (2b) addasync
keyword in front offunction
keyword (that's all, do not adjust function body content)To avoid making this PR too problematic to review, nothing more should be covered in PR.
It's likely this PR will already expose some issues, as Framework has logic parts where promise returning functions are in some scenarios treated as sync and in other as async. All handling like that should be fixed with this PR.
As project covers a lot of files, let's split this work into multiple PR's each covering following areas:
lib
andlib/classes
lib/plugins/aws/customResources
(refactor: Mark functions async inaws/customResources
andaws/deploy
#8698)lib/plugins/aws/deploy
(refactor: Mark functions async inaws/customResources
andaws/deploy
#8698)lib/plugins/aws
(refactor: Useasync/await
inlib/plugins/aws
. #8871)lib/plugins/aws/info
(refactor: Useasync/await
inlib/plugins
. #8875)lib/plugins/aws/invokeLocal
(refactor: Useasync/await
inlib/plugins/aws/invokeLocal
. #8876)/lib/plugins/aws/lib
(refactor: Use async inlib/plugins/aws/lib
#8872)lib/plugins/aws/package/compile/events/alb
,lib/plugins/aws/package/compile/events/lib
,lib/plugins/aws/package/compile/events/s3
and files put directly intolib/plugins/aws/package/compile/events
(refactor: Useasync
inaws/package/compile/events
#8873)lib/plugins/aws/package/compile/events/websockets
(refactor: Useasync
incompile/events/websockets
#8874)lib/plugins/aws/package/compile/events/apiGateway
(refactor: Useasync/await
inevents/apiGateway
. #8869)lib/plugins/aws/package/compile
(refactor: Useasync
inlib/plugins/aws/package
#8870)lib/plugins/aws/package/lib
and files put directly intolib/plugins/aws/package
(refactor: Useasync
inlib/plugins/aws/package
#8870)lib/plugins/aws/remove
lib/plugins/aws/utils
lib/plugins
(refactor: Useasync/await
inlib/plugins
. #8875)lib/plugins/create
(refactor: Useasync
inlib/plugins/create
#9683)lib/plugins/interactiveCli
(was addressed with extensive feature refactor)lib/plugins/package
(refactor: Useasync
inlib/plugins/package
#9644)lib/plugins/plugin
lib/utils
(refactor: Useasync
inlib/utils
#9809)scripts
test/integration
test
,test/unit/lib
,test/unit/lib/plugins
test/unit/lib/classes
test/unit/lib/plugins/aws/common
test/unit/lib/plugins/aws/deploy
test/unit/lib/plugins/aws
,test/unit/lib/plugins/aws/package
,test/unit/lib/plugins/aws/package/compile
test/unit/lib/plugins/aws/info
test/unit/lib/plugins/aws/lib
andtest/unit/lib/plugins/aws/invokeLocal
test/unit/lib/plugins/aws/package/compile/events/s3
,test/unit/lib/plugins/aws/package/compile/events/alb
andtest/unit/lib/plugins/aws/package/compile/events/lib
/test/unit/lib/plugins/aws/package/compile/events/apiGateway
test/unit/lib/plugins/aws/package/compile/events
test/unit/lib/plugins/aws/package/compile/events/websockets
test/unit/lib/plugins/aws/package/compile
test/unit/lib/plugins/aws/package/lib
and files put directly intotest/unit/lib/plugins/aws/package
test/unit/lib/plugins/aws/remove
test/unit/lib/plugins/aws/utils
test/unit/lib/plugins/create
and files put directly intotest/unit/lib/plugins
test/unit/lib/plugins/interactiveCli
test/unit/lib/plugins/package
test/unit/lib/plugins/plugin
test/unit/lib/utils
test/utils
The text was updated successfully, but these errors were encountered: