Does the SST cli (locally) treat lambda functions ...
# help
k
Does the SST cli (locally) treat lambda functions that are hooked up to dynamodb streams in any way different from lambda functions that are triggered by api gateway ?
t
No it shouldn't
what are you seeing?
s
I've seen DDB stream lambdas fire in the live lambda dev environment
k
Interesting, I am having a weird error with my DB connection to a local mysql instance, the function that is hooked up to the stream is connecting without issues the function that is invoked by the API is getting rejected by mysql with
Copy code
Aborted connection 28 to db: 'db_name' user: 'user_name' host: '172.19.0.1' (Got an error reading communication packets)
the env.. is the same the connection config is the same
t
Does the error message have the values from the connection config?
k
Nope that is all I am getting
t
I mean is this correct:
host: '172.19.0.1'
k
On the SST side
Copy code
Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'constructor' of undefined","reason":"TypeError: Cannot read property 'constructor' of undefined","promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'constructor' of undefined","    at process.<anonymous> (/Users/kujtimhoxha/git/devstride/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:58:23)","    at process.emit (events.js:400:28)","    at process.emit (domain.js:475:12)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
dcbf939f-7d37-412d-b527-67231e62cefd ERROR Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'constructor' of undefined
t
I imagine that should be pointing to localhost right
k
The first message is the mysql instance
I have it running on docker, the super weird thing is that it is the same instance and the same config and the 2 functions behave differently
t
can you verify in the AWS console the environment variables are there and look right?
for the lambda
Oh the error was from the docker mysql hm so the function is trying to connect
If you set NODE_OPTIONS=--enable-source-maps on the function you might get a more useful error
k
Yeah I’ll try that, I verified the connection config is the same
Ok this is super weird, I just made a small change to the function (I just randomly changed the timeout) and the function redeployed and now it works
without any changes
I reverted the timeout and it still is working
I have no clue why 😅
Ok found out why 😂 obviously it was my fault… I had a function that was a promise but I forgot to
await
and that function threw an error because of what I was sending to the API… that in turn closed the connection to mysql 😂
This is a combination of 2 stupid mistakes 😂
s
Ahh yes, happens to me all the time
t
Ohhhh
k
I lost a couple of hours because of an
await
🤦‍♂️