Skip to content
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

ConnectionError - Session terminated by database without notifying the library #409

Open
linhub15 opened this issue Sep 19, 2022 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@linhub15
Copy link

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?

@linhub15
Copy link
Author

Would it be wrong to recursively call Connection.query(...)?

} catch (e) {
if (e instanceof ConnectionError) {
await this.end();
}
throw e;
} finally {
this.#queryLock.push(undefined);

} catch (e) { 
   if (e instanceof ConnectionError) { 
     await this.end();
+    return await this.query(query);
   } 
   throw e;
 } finally {
   this.#queryLock.push(undefined);

@bombillazo bombillazo added help wanted Extra attention is needed bug Something isn't working labels Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants