-
Notifications
You must be signed in to change notification settings - Fork 395
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
Discussion: Running Bolt apps on Function-as-a-Service #361
Comments
If it helps at all I had some success running Bolt on Lambda in this app by using the express receiver and |
@threesquared Thanks for your comment. Yes, for simple apps, it works mostly. If a Bolt app has time-consuming |
With Bolt v2, it'll be much safer to build a Bolt app with FaaS. The app.command("/echo", async ({ say, ack }) => {
say("something").then(() => ack());
});
function doSomething(): Promise<string> { ... }
app.command("/echo", async ({ ack }) => {
doSomething().then(() => ack());
}); In addition, I'll come up with the initial version of the |
If you're curious about the improvements for |
Seeing as we have a solution that we've converged on, I think we can safely close this issue. I think the discussion portion of this problem is done. What do you think @seratch? |
You're right. We can safely close this ticket as we've merged some effective changes for listeners. Regarding #395 (more specific one for Events API), I'd like to hold off closing as it's still in progress (we haven't merged @stevengill's PR yet). But we can close #361 now. Thanks for taking care of this. |
Description
Disclaimer
Creating this issue doesn't mean the Bolt team is going to provide a proper way to support FaaS (e.g., AWS Lambda, Google Cloud Functions, Cloud Functions for Firebase, etc.) in the short run.
I wanted to create a place to discuss any future possibilities to support FaaS in some ways.
The challenge we have with FaaS
One limitation you should know when you run Bolt apps on FaaS is that any asynchronous operations can be silently terminated once its internet-facing function responds to an incoming HTTP request from Slack.
Examples of "asynchronous operations" here are
say
,respond
,app.client
calls, and whatever internally startsPromise
operations separately fromack()
completion.Let's say you want to create an AWS Lambda function that is free from Slack's 3-second timeouts and the limitation I mentioned above. In this case, the following code is a solution.
One possible idea I came up with
Let me refer to my comment in another issue: #353 (comment)
If Bolt changes its APIs and internals, it may be feasible to have a 3rd-party generalized npm package that offers proper FaaS supports for Bolt.
Here is my prototype demonstrating it: https://github.com/seratch/bolt-aws-lambda-proof-of-concept
It doesn't support all the features yet but it just works for supported cases.
Here is a simple example code (just pasted from the repository's README).
Now developers don't need to directly use AWS Lambda SDK.
AwsLambdaReceiver
does everything for you: https://github.com/seratch/bolt-aws-lambda-proof-of-concept/blob/7b72a5e416977036e98c4bfbf40ee0567910766c/src/added/AwsLambdaReceiver.ts#L174-L189Apart from the things specific to AWS, this approach is applicable to any others (not only FaaS).
In this design, the two phases are:
respond
to send a message to a user asynchronouslyPhase 2 function is supposed to return a single
Promise
as its result. The design makes easier to write code in idiomatic ways (like usingthen
/catch
and/orPromise.all
) for working withPromise
s.Next steps
If someone is interested in starting with my PoC prototype to build a 3rd-party library, I'm happy to donate my code (it's under the MIT license) and will be more than happy to contribute to it as an individual.
To realize such 3rd parties, a few changes on the Bolt side are still needed. @aoberoi shared a related proposal at #353. Join the conversation to share your thoughts and/or feedback.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: