https://serverless-stack.com/ logo
#help
Title
# help
m

Meris Tarhanis

04/26/2022, 1:08 PM
Hello everyone. Just for info I am using RDS(Postgres) with my SST for the backend. My SST version is "0.65.6". I am having an issue with:
Copy code
Failed to send response because the lambda function is disconnected
How it happens: • I send API request to my API • API recognizes the request and triggers the right lambda • lambda starts doing its work, parses in the data from the request body, sends the query to the RDS etc.. • I receive the Internal Server Error, 500 as response to my request • SST send me the above message ("Failed to send response because the lambda function is disconnected") • SST prints out the "real" response Message in the console, (200, body of a successful request*) What I think is the problem: My lambda function doesn't wait for the Response from the DB before sending it back to the client. So my question is, how do I make my lambda functions pre-connect to the RDS and wait out for the response?
r

Ross Coundon

04/26/2022, 1:17 PM
You can pass --increase-timeout to sst start
m

Meris Tarhanis

04/26/2022, 1:19 PM
Hey @Ross Coundon thank you for the response, but I already knew that I said to my self that I will use it as a last resort 😄. I am looking for an optimal solution here, that won't consume more resources.
r

Ross Coundon

04/26/2022, 1:20 PM
I'm not sure there's much else you can do, the max timeout for api gateway is a limiting factor at 30s
t

thdxr

04/26/2022, 1:22 PM
This might be related to a bug that we fixed in 1.0
actually never mind, you just need to set RDS not to scale to zero
in production you probably never want that
for local development it's fine to scale to 0
m

Meris Tarhanis

04/26/2022, 1:23 PM
So what are you advising @thdxr?
t

thdxr

04/26/2022, 1:24 PM
hm actually I think by default we don't scale to 0
the example is probably what you want
m

Meris Tarhanis

04/26/2022, 1:25 PM
So to never pause the DB?
t

thdxr

04/26/2022, 1:25 PM
yeah for prod
but autopausing is good for local development, you don't want it running when you're not around
m

Meris Tarhanis

04/26/2022, 1:31 PM
Okay @thdxr thanks, will try it out now. Will report back the results.
There seems to be a problem @thdxr , I tried to use the link that you have sent me, and I am getting this error now:
t

thdxr

04/26/2022, 2:41 PM
@Frank is this a bug possibly?
m

Meris Tarhanis

04/26/2022, 2:46 PM
@thdxr I'll try updating to newest version of SST and try again
f

Frank

04/26/2022, 3:32 PM
@Meris Tarhanis @thdxr lemme take a look..
@Meris Tarhanis I was not able to reproduce ur issue.
The RDS is defined similar to the screenshot you shared https://github.com/fwang/sst-triage-rds-autopause/blob/main/stacks/MyStack.js#L7-L13
Can u follow the steps in the README and see if you can build this app?
Leaving a note here,
autoPause
was set to
process.env.AUTO_PAUSE
which has a string value ie.
"true"
, changing it to
process.env.AUTO_PAUSE === "true"
worked.
2 Views