Skip to content

Commit

Permalink
fix: recursion (#1380)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Dec 18, 2024
1 parent 9084674 commit c7142d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/abacus-ts/lib/createStoreEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export function createStoreEffect<T>(
const removeStoreListener = store.subscribe(() => {
const thisValue = selector(store.getState());
if (thisValue !== lastValue) {
lastCleanup?.();
lastValue = thisValue;
// NOTE: some cleanups dispatch actions which cause this to happen recursively.
// we must ensure that those actions don't change the state they subscribe to or this will go infinitely
lastCleanup?.();
lastCleanup = handleChange(thisValue);
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/abacus-ts/websocket/lib/indexerWebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class IndexerWebsocket {
const message = isWsMessage(messagePre);
if (message.type === 'error') {
logAbacusTsError('IndexerWebsocket', 'encountered server side error:', message.message);
} else if (message.type === 'connected') {
} else if (message.type === 'connected' || message.type === 'unsubscribed') {
// do nothing
} else if (
message.type === 'subscribed' ||
Expand Down Expand Up @@ -200,6 +200,7 @@ type IndexerWebsocketMessageType =
subaccountNumber?: number;
contents: any;
}
| { type: 'subscribed'; channel: string; id: string | undefined; contents: any };
| { type: 'subscribed'; channel: string; id: string | undefined; contents: any }
| { type: 'unsubscribed'; channel: string; id: string | undefined; contents: any };

export const isWsMessage = typia.createAssert<IndexerWebsocketMessageType>();

0 comments on commit c7142d4

Please sign in to comment.