Skip to content

Commit 5b43704

Browse files
committed
fix: release form handle when set(IDLE) finds no subscribers
When a component unmounts during an in-flight submit, the subscribe cleanup skips release() because state !== IDLE. When the write later resolves and set(IDLE) runs, there are no subscribers left but set() never called release(), leaving the handle in the store's forms map for the rest of the session. Add a release check in set() so an idle handle with zero subscribers is collected regardless of whether the last subscriber left before or after the state returned to IDLE.
1 parent 35c8cb2 commit 5b43704

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎packages/octane/src/data/form.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export function createFormHandle<I, O>(
152152
const set = (next: FormState) => {
153153
state = next;
154154
for (const notify of [...subscribers]) notify();
155+
if (subscribers.size === 0 && next === IDLE) release();
155156
};
156157
const base: Array<readonly [string, string]> = [[FORM_WRITE, write.name]];
157158
if (key) base.push([FORM_KEY, key]);

0 commit comments

Comments
 (0)