Skip to content

Commit

Permalink
fix: improve failure state handling for sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed May 20, 2024
1 parent 0343733 commit 65200aa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/utils/src/abstract-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,16 @@ export abstract class AbstractSession<Provider, RetrieveBlockProgressEvents exte
this.log.error('error finding new providers for %c', cid, evt.detail.error)

findProvidersErrored = true
if (foundBlock) {
// we found the block, so we can ignore this error
return
}

Check warning on line 117 in packages/utils/src/abstract-session.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/abstract-session.ts#L115-L117

Added lines #L115 - L117 were not covered by tests
if (['ERR_INSUFFICIENT_PROVIDERS_FOUND'].includes((evt.detail.error as CodeError).code)) {
deferred.reject(evt.detail.error)
this.log.error('insufficient providers found for %c', cid)
if (this.queryProviderQueue.running === 0) {
// only reject if we're not currently querying any providers
deferred.reject(evt.detail.error)
}
}
})

Expand Down

0 comments on commit 65200aa

Please sign in to comment.