TypeError: fetch failed] { cause: [Error: AggregateError] }
Steps to reproduce
const sql = neon(process.env.POSTGRES_URL_NON_POOLING);
return await sql(query, params);
Expected result
Return rows
Actual result
Error
Environment
Vercel Edge Runtime
Logs, links
Work with Kysely and Pool, but this does not work:
const sql = neon(process.env.POSTGRES_URL_NON_POOLING);
return await sql(query, params);
[NeonDbError: Error connecting to database: fetch failed] {
name: 'NeonDbError',
severity: undefined,
code: undefined,
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: undefined,
line: undefined,
routine: undefined,
sourceError: [TypeError: fetch failed] { cause: [Error: AggregateError] }
}
Thanks for the report.
There's an example project using HTTP on Vercel Edge Functions at https://github.com/neondatabase-labs/neon-vercel-http/blob/main/api/sites.ts, and deployed at https://neon-vercel-http-pn9w6ym59-jawjs-projects.vercel.app.
I just updated it to the latest driver version, and it seems to be working OK.
The first thing to check is probably just that the POSTGRES_URL_NON_POOLING environment variable is populated as expected. If that doesn't help, can you post a minimal test case to help us reproduce the issue?
@jawj POSTGRES_URL_NON_POOLING works with Kysely, but with one-shot query directly using Neon does not work.
I'm happy to investigate this but first I need something I can reproduce. As I mentioned, our own example app using http from Vercel Edge Functions is working fine.
@jawj Maybe this is because I'm running Neon locally in Docker. Also, the query is quite complex and with Kysely executeQuery it tries to use CompressionStream, which is not available in Edge Runtime.
A possible solution would be doing this