Skip to content

Commit

Permalink
fix(): use to retry option
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Sep 1, 2020
1 parent 687fb66 commit 986ee91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/common/typeorm.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ export function handleRetry(
retryDelay = 3000,
connectionName = DEFAULT_CONNECTION_NAME,
verboseRetryLog = false,
toRetry?: (err: any) => boolean,
): <T>(source: Observable<T>) => Observable<T> {
return <T>(source: Observable<T>) =>
source.pipe(
retryWhen((e) =>
e.pipe(
scan((errorCount, error: Error) => {
if (toRetry && !toRetry(error)) {
throw error;
}
const connectionInfo =
connectionName === DEFAULT_CONNECTION_NAME
? ''
Expand Down
1 change: 1 addition & 0 deletions lib/typeorm-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export class TypeOrmCoreModule implements OnApplicationShutdown {
options.retryDelay,
connectionToken,
options.verboseRetryLog,
options.toRetry,
),
)
.toPromise();
Expand Down

0 comments on commit 986ee91

Please sign in to comment.