Skip to content

Why is a connection destroyed when there is an error thrown from the connection handler? #721

@notcome

Description

@notcome

I noticed that if the connection handler throws any error, the connection itself is destroyed:

try {
result = await connectionHandler(
connectionLog,
connection,
boundConnection,
clientConfiguration,
);
} catch (error) {
await connection.destroy();
throw error;
}

Is this really necessary? It feels wrong when:

  1. If we are simply throwing an error to indicate an application logic, that connection must destroyed and recreated.
  2. If we are doing a transaction and want to rollback, that connection must be destroyed and recreated.

Shouldn't we only destroy the connection when there is some underlying issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions