-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
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.
const dbClient = createClient({
url: DB_URL,
authToken: DB_AUTH_TOKEN,
});
export async function handler(
event: CloudFrontRequestEvent
): Promise<CloudFrontRequestResult> {
// Use `dbClient` here
}Testing just now, my first request was processed correctly but on the second request I got:
2023-09-30T02:44:21.779Z cdd6ee8d-b573-40e8-8871-224a0551d468 ERROR Invoke Error
{
"errorType": "FetchError",
"errorMessage": "request to https://jpdict-dev-birchill.turso.io/v2/pipeline failed, reason: socket hang up",
"code": "ECONNRESET",
"message": "request to https://jpdict-dev-birchill.turso.io/v2/pipeline failed, reason: socket hang up",
"type": "system",
"errno": "ECONNRESET",
"stack": [
"FetchError: request to https://jpdict-dev-birchill.turso.io/v2/pipeline failed, reason: socket hang up",
" at ClientRequest.<anonymous> (/var/task/index.js:7054:18)",
" at ClientRequest.emit (node:events:514:28)",
" at TLSSocket.socketCloseListener (node:_http_client:474:11)",
" at TLSSocket.emit (node:events:526:35)",
" at node:net:323:12",
" at TCP.done (node:_tls_wrap:588:7)"
]
}
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 of better-sqlite3.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels