-
Notifications
You must be signed in to change notification settings - Fork 39
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
Socket hang up with Lambda with JS client #110
Comments
Actually, even after moving the initialization of the client into the handler I still encounter this so it doesn't appear to be related to long-lived client instances. |
Hey @birtles, you are importing Let's keep this issue open though, maybe there's something on the client side we can do to improve this. |
Hi! I'm just importing
Perhaps I just never tested 0.3.4 enough to come across this then. If the best practice is to open the connection from the handler (i.e. on each request) then I can live with that. If there's a way to persist it/re-establish it, however, all the better. |
Hmm, I'm still getting occasional socket hang ups even when creating the client from the handler. I might try using a regular Lambda instead to see if it's particular to Lambda@Edge. |
I rewrote the Lambda as a regular Lambda in both TS and Rust and I still see the hang-ups in the Node (TS) version but I've never seen them with the Rust one. This is even when the client is created inside the handler. It looks like this is related to aws/aws-sdk-js-v3#1196. One comment on that issue mentions:
So I guess our TS client needs to be looking for and retrying errors, perhaps here I guess? At the moment I think the only way to work around this is for users to wrap every call to (Updated to clarify that this is the case even when the client is created inside the handler.) |
@birtles Sorry for joining the party late, but here's first take on making the fetch() retry: libsql/hrana-client-ts#9 I still need to convince myself that it's safe, but if anyone experiencing this issue can test the pull request, that would help a lot. |
Thanks! Like @mateusfreira pointed out, that doesn't look right to me since it's not waiting on the fetch. Unfortunately I've switched to Rust for the Lambda I was encountering this on (largely because the TS client was so unreliable) so I'm not able to verify the fix I'm afraid. |
I have a Lambda@Edge function (origin request) that uses @libsql/client to query Turso.
It initializes the client in the global scope (i.e. not in the handler) as is common practice in Lambdas so you can re-use the client across subsequent invocations.
e.g.
Testing just now, my first request was processed correctly but on the second request I got:
Is there some lifetime to the connection I need to be aware of? Some way to force a persistent connection? Or should I just create a new client for each invocation?
For what it's worth I am using version 0.3.5 but I never saw this error with version 0.3.4 so I suppose it might be related to using
libsql
instead ofbetter-sqlite3
.The text was updated successfully, but these errors were encountered: