You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently ran into an issue where code that runs after a call to res.json in a given route is not guaranteed to be run before a lambda ends.
My use-case is as follows -
PUT /posts/1
handle database update in route
return updated record to client using res.json
as an after middleware, send event specifying something was changed to AWS SQS
In a regular express server, I expect that the code in step 4 would complete successfully. However, I believe that serverless-express is ending the invocation of the lambda before that code has a chance to complete under certain circumstances.
To be a little more clear, here is a set of logs that represents a successful invocation -
As you can see, under some circumstances, the lambda invocation ends before the process has a chance to complete writing to SQS.
Is it possible that this use-case is not well supported in serverless-express? Let me know if more information is needed or if I am obviously doing something wrong.
The text was updated successfully, but these errors were encountered:
I recently ran into an issue where code that runs after a call to
res.json
in a given route is not guaranteed to be run before a lambda ends.My use-case is as follows -
PUT /posts/1
res.json
In a regular express server, I expect that the code in step 4 would complete successfully. However, I believe that serverless-express is ending the invocation of the lambda before that code has a chance to complete under certain circumstances.
To be a little more clear, here is a set of logs that represents a successful invocation -
and here is a set of logs that represents an unsuccessful invocation -
As you can see, under some circumstances, the lambda invocation ends before the process has a chance to complete writing to SQS.
Is it possible that this use-case is not well supported in serverless-express? Let me know if more information is needed or if I am obviously doing something wrong.
The text was updated successfully, but these errors were encountered: