postgres
postgres copied to clipboard
`ConnectionError` - Session terminated by database without notifying the library
Using a cloud managed DB often terminates sessions without notifying the library. This causes ConnectionError because the library was not notified of the cancelled connection.
There is a TODO comment mentioned that this will be fixed.
... will be removed once we move to async handling of messages by the frontend ... https://github.com/denodrivers/postgres/blob/main/connection/connection.ts#L167-L171
Is there a workaround in the meantime?
Would it be wrong to recursively call Connection.query(...)?
https://github.com/denodrivers/postgres/blob/8a07131efa17f4a6bcab86fd81407f149de93449/connection/connection.ts#L953-L959
} catch (e) {
if (e instanceof ConnectionError) {
await this.end();
+ return await this.query(query);
}
throw e;
} finally {
this.#queryLock.push(undefined);