Skip to content

Commit

Permalink
fix(ibmi): reconnect when connection drops because of 08S01 error (#1…
Browse files Browse the repository at this point in the history
…6259)

Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
  • Loading branch information
rcronin and WikiRik committed Sep 23, 2023
1 parent 6398334 commit 3e993f3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/dialects/ibmi/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ export class IBMiQuery extends AbstractQuery {
-803, // A violation of the constraint imposed by a unique index or a unique constraint occurred.
];

/**
* Check for ODBC connection errors by looking at the SQL state. This will allow for an IPL
* on the IBM i to be detected and the connection to be re-established.
*/
if (odbcError.state === '08S01') {
return new sequelizeErrors.ConnectionRefusedError(err);
}

if (foreignKeyConstraintCodes.includes(odbcError.code)) {
return new sequelizeErrors.ForeignKeyConstraintError({
cause: err,
Expand Down

0 comments on commit 3e993f3

Please sign in to comment.