Skip to content

Commit

Permalink
fix: Fix when to check connection
Browse files Browse the repository at this point in the history
Since all sources can now control if they need to check connection or not do not restrict to just those that can poll
  • Loading branch information
FoxxMD committed Jan 23, 2024
1 parent 3351365 commit 54b9ece
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/backend/sources/AbstractSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,21 @@ export default abstract class AbstractSource implements Authenticatable {
}

public async checkConnection() {
if (this.canPoll) {
try {
const res = await this.doCheckConnection();
if (res === undefined) {
this.logger.debug('Connection check was not required.');
this.connectionOK = null;
return;
} else if (res === true) {
this.logger.verbose('Connection check succeeded');
} else {
this.logger.verbose(`Connection check succeeded => ${res}`);
}
this.connectionOK = true;
} catch (e) {
this.connectionOK = false;
throw new ErrorWithCause('Communicating with upstream service failed', {cause: e});
try {
const res = await this.doCheckConnection();
if (res === undefined) {
this.logger.debug('Connection check was not required.');
this.connectionOK = null;
return;
} else if (res === true) {
this.logger.verbose('Connection check succeeded');
} else {
this.logger.verbose(`Connection check succeeded => ${res}`);
}
this.connectionOK = true;
} catch (e) {
this.connectionOK = false;
throw new ErrorWithCause('Communicating with upstream service failed', {cause: e});
}
}

Expand Down

0 comments on commit 54b9ece

Please sign in to comment.