Run a script before returning response to Lambda? #585
-
Hi. Awesome adapter!! Thank you. :) Quick question: Is there an option to run a script before returning the response back to Lambda? Use case: I am using an existing JAR server in my docker. I can't change the code in this JAR file. However, I would like to run a custom script after the JAR server returns the response, before the response is forwarded to Lambda. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
This is not supported in the current version. I think it is valuble to have this capability. Will it affect your use case if the scripts runs async while the response is forwarded to Lambda? This reduces the response latency to the client. |
Beta Was this translation helpful? Give feedback.
-
Thanks for for your reply! Yes, as long as the script runs after the webserver responds, that serves our use-case. (My understanding was that AWS can put the execution environment to sleep as soon as the response is forwarded to Lambda, so the script execution may not take place after returning the response) |
Beta Was this translation helpful? Give feedback.
-
Lambda Web Adapter is both a Lambda extension and a runtime api client. Lambda extension is allowed to run after the response is sent. |
Beta Was this translation helpful? Give feedback.
-
Great! In my use-case, the script just takes a few milliseconds to run - so either way works for me. But I suppose execution after response will be a better user experience. |
Beta Was this translation helpful? Give feedback.
This is not supported in the current version. I think it is valuble to have this capability.
Will it affect your use case if the scripts runs async while the response is forwarded to Lambda? This reduces the response latency to the client.