Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/typescript-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export class ShapeStream<T extends Row<unknown> = Row>
#fastLoopMaxCount = 5
#pendingRequestShapeCacheBuster?: string
#maxSnapshotRetries = 5
_expiredShapeRecoveryKey: string | null = null

constructor(options: ShapeStreamOptions<GetExtensions<T>>) {
this.options = { subscribe: true, ...options }
Expand Down Expand Up @@ -1241,6 +1242,14 @@ export class ShapeStream<T extends Row<unknown> = Row>
// Cancel the response body to release the connection before retrying.
await response.body?.cancel()
if (transition.exceededMaxRetries) {
if (shapeKey && this._expiredShapeRecoveryKey !== shapeKey) {
this._expiredShapeRecoveryKey = shapeKey
expiredShapesCache.delete(shapeKey)
this.#reset()
throw new StaleCacheError(
`Expired handle entry evicted for self-healing retry`
)
}
throw new FetchError(
502,
undefined,
Expand Down