Skip to content

Commit 15f1b19

Browse files
authored
Fix failed event on retry exhausted (#651)
On send the failed event from the `CoreNode` when the `retry` count has exhausted and we've stopped retrying.
2 parents 4713220 + d1b0d64 commit 15f1b19

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/core/CoreNode.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,16 @@ export class CoreNode extends EventEmitter {
918918
this.notifyParentRTTOfUpdate();
919919
}
920920

921-
this.emit('failed', {
922-
type: 'texture',
923-
error,
924-
} satisfies NodeTextureFailedPayload);
921+
// only emit failed outward if we've exhausted all retry attempts
922+
if (
923+
this.texture !== null &&
924+
this.texture.retryCount > this.texture.maxRetryCount
925+
) {
926+
this.emit('failed', {
927+
type: 'texture',
928+
error,
929+
} satisfies NodeTextureFailedPayload);
930+
}
925931
};
926932

927933
private onTextureFreed: TextureFreedEventHandler = () => {

src/core/textures/SubTexture.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export class SubTexture extends Texture {
137137
};
138138

139139
private onParentTxFailed: TextureFailedEventHandler = (target, error) => {
140+
//decrement with 1 because in the failed state it will do +1 again.
141+
this.retryCount = this.parentTexture.retryCount - 1;
140142
this.forwardParentTxState('failed', error);
141143
};
142144

0 commit comments

Comments
 (0)