Skip to content

Commit

Permalink
fix(datasource-sql): improve the connect management errors (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scra3 authored Jun 9, 2023
1 parent e079442 commit 1128e49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/datasource-sql/src/connection/handle-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function handleProxyErrors(
): void {
// eslint-disable-next-line max-len
// @link: list of errors thrown by the proxy https://github.com/JoshGlazebrook/socks/blob/76d013e4c9a2d956f07868477d8f12ec0b96edfc/src/common/constants.ts#LL10C10-L10C10
if (error?.stack.includes('SocksClient')) {
if (error?.stack?.includes('SocksClient')) {
if (
error.message.includes('Socket closed') ||
error.message.includes('Socks5 proxy rejected connection')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ describe('handleErrors', () => {
});
});

describe('when the error has an empty stack trace', () => {
it('should throw an error', () => {
const error = new Error('An error');
error.stack = null;
expect(() => handleErrors(error, null, null)).toThrow(error);
});
});

describe('when the error is thrown by the proxy', () => {
describe('when the proxy has an error with database uri', () => {
it('should throw an error', () => {
Expand Down

0 comments on commit 1128e49

Please sign in to comment.