Skip to content

fix(compiler): require Strong effect cleanup to cancel or ignore async state updates - #1482

Merged
trueadm merged 41 commits into
mainfrom
feat/strong-effect-async-cleanup
Oct 1, 2026
Merged

trueadm merged 41 commits into
mainfrom
feat/strong-effect-async-cleanup

Conversation

@trueadm

@trueadm trueadm commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Second of four stacked Strong effect PRs (tracking issue #1027). This branch contains #1481; merge that first. The change for this PR is the top commit, "require Strong effect cleanup to cancel or ignore async state updates".

OCTANE_STRONG_EFFECT_DATA_FETCH only recognized fetch, and any returned cleanup satisfied it. An imported client such as api.get(id).then(setD), axios, or a return () => {} cleanup therefore compiled cleanly.

What changed. Any state update that runs after an await, or in a .then/.catch/.finally callback, of work the effect started now needs proof that the returned cleanup cancels or ignores it. One of these must hold:

  • Abort. The cleanup calls abort() on an AbortController created in the effect, and the controller's signal reaches the request whose result the update follows. The signal can be passed directly, through const { signal } = controller or controller.signal aliases, inside an options object including spreads, or through a same-module helper's parameter. A controller.signal.aborted guard also works.
  • Flag. The cleanup assigns a let flag declared in the effect, and a test of that flag guards the update after the last yield. Supported forms are if (!ignore), if (ignore) return;, active && …, ignore || …, and === true/false. The flag's polarity must contradict the value the cleanup writes.

These are rejected:

  • empty cleanups;
  • opaque cleanups;
  • flags the update never checks;
  • guards with the wrong polarity;
  • guards checked before a later await;
  • component-scoped, module-scoped, and ref flags, because every run shares them;
  • controllers whose signal never reaches the request;
  • aborts of the wrong controller;
  • updates passed straight to .then(setX), which a flag cannot guard.

Async effect callbacks get their own message, since they cannot return cleanup. Messages name use()/query bindings, the abort pattern, and the flag pattern.

This replaces the fetch-only continuation tracking in strong-mode.js with guard, flow-segment, and promise-source tracking in strong-effects.js. Deferred constructors and tagged templates in effect-owned work are now followed like calls. The docs line that admitted returning cleanup "does not prove stale results are cancelled" is replaced by a new "Effect cleanup" section in docs/strong-compiler-checks.md.

Validation

  • pnpm format:check: repo-wide, run on the complete stack; pnpm format:files:check on this layer.
  • pnpm typecheck: full run on the complete stack. pnpm typecheck:files on the changed tests shows only the TS7016 errors main already has.
  • pnpm test: run on the complete stack through the four CI shards. All passed except the known hmr.test.ts load timeout, which passes 74/74 in isolation (details in fix(compiler): count zero-delay effect callbacks and custom-hook updaters as Strong effect setup #1481).
  • targeted tests: the five Strong suites pass on this layer (1281 tests).
    • The item-3 snippets (api.get, axios, empty cleanup) are rejected.
    • There are accept and reject tables for every abort and flag form above, the likely rewrites, and same-module helpers that carry the signal or the flag.
    • Output pins are unchanged, and the Volar diagnostics are source-located.
  • pnpm sync produced no changes.

Risk / follow-ups

  • Intended fixture flips:
    • The old "any cleanup is fine" fixtures now expect OCTANE_STRONG_EFFECT_DATA_FETCH.
    • The yield matrices' effect variants now expect it too, because an update after a pending await with no cleanup is exactly this case.
    • Effect-chain fixtures now use guarded async writers.
  • Stale-result patterns that now fail in real repo code if it opts into Strong:
    • The latest-request "generation counter" ref pattern (examples/relay, streamdown's mermaid renderer). It reads a ref in setup and has no cancelling cleanup.
    • A view transition's finished.finally(setX).
  • Bounded by design:
    • A cleanup returned on any path counts.
    • Conditions inside the cleanup are not evaluated.
    • Aborting a request does not stop its .catch from running, so guard updates there with the flag or signal.aborted.
    • A cleanup returned by an imported helper is opaque.
  • Pre-existing on main, not changed here: in try { await x; … } catch (e) { if (!ignore) setErr(e) }, the catch clause is analyzed as possibly synchronous, so it reports OCTANE_STRONG_EFFECT_STATE_UPDATE. That is being handled separately.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Strong-mode compile-time breaking change for opted-in modules (e.g. api.get().then(setState) or noop cleanup); runtime output unchanged for code that still compiles.

Overview
Tightens Strong mode effect rules in the compiler only—emitted code for valid modules stays the same.

Async effect writes (OCTANE_STRONG_EFFECT_DATA_FETCH). The check no longer targets fetch plus “any cleanup.” Any state update after an await or in a .then/.catch/.finally from effect-owned work must be provably cancelled or ignored: cleanup aborts an AbortController whose signal reaches that request (including chained .json() and same-module helpers), or cleanup sets a let flag inside the effect that guards the update after the last yield. Empty/opaque cleanups, ref/module/component flags, and unconnected aborts are errors; async effect callbacks get a dedicated message.

Synchronous-setup bypasses (OCTANE_STRONG_EFFECT_STATE_UPDATE). State updates through startTransition, useTransition starts, queueMicrotask, settled Promise.resolve/reject chains, zero-delay setTimeout, and await of non-pending values are treated like direct effect setup. The visitor follows state tuples, updaters, and transition handles returned from same-module custom hooks, with per-call state identity for effect-chain analysis.

Implementation moves lifecycle proofs into strong-effects.js and rewires strong-mode.js (flow segments, guards, jump targets, cleanup scanning). Docs, MCP skills, and a large strong-effects.test.ts suite document and lock the behavior.

Reviewed by Cursor Bugbot for commit e0961ae. Bugbot is set up for automated code reviews on this repo. Configure here.

trueadm and others added 2 commits October 1, 2026 00:50
…ters as Strong effect setup

OCTANE_STRONG_EFFECT_STATE_UPDATE could be bypassed by deferring the update
by zero delay or by returning the state tuple from a same-module custom hook.

Callbacks that run before the next paint now count as synchronous effect
setup: startTransition (imports, aliases, namespaces, optional calls), a
useTransition start function, queueMicrotask, .then/.catch/.finally on
Promise.resolve(value) or Promise.reject(), setTimeout without a positive
delay, and code after awaiting a value that is not a pending promise.
requestAnimationFrame, positive-delay timers, and external subscription
callbacks remain event-driven.

Synchronous calls to local functions now record what they return, so state
tuples, updaters, callbacks, and transition starts returned by same-module
custom hooks keep their provenance in the caller. Each call gets its own
state identity so separate calls never read as one state in effect graphs.

The classification lives in a new strong-effects.js policy module. Emitted
code and compatibility modules are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…c state updates

OCTANE_STRONG_EFFECT_DATA_FETCH only recognized fetch, and any returned
cleanup satisfied it, so an imported client, axios, or an empty cleanup
silenced the check.

Any state update that runs after an await, or in a .then/.catch/.finally
callback, of effect-owned work now needs proof that the returned cleanup
cancels or ignores it:

- the cleanup aborts an AbortController created in the effect whose signal
  reaches the request (directly, through aliases or destructuring, in an
  options object, or through a same-module helper parameter), or the update
  is guarded by that signal's aborted flag; or
- the cleanup assigns a let flag declared in the effect, and the update is
  guarded by that flag after the last await (if tests, early returns, &&/||).

Empty, opaque, and unconnected cleanups, component- or module-scoped flags,
ref flags, and guards checked before a later await are errors. Async effect
callbacks cannot return cleanup and get a message that says so.

This replaces the fetch-only continuation tracking in strong-mode.js with
guard, flow-segment, and source tracking in strong-effects.js. Deferred
constructors and tagged templates in effect-owned work are now followed like
calls. Emitted code and compatibility modules are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Abort proofs leak across later work
    • Added save/restore of effectPolicy flow around each exclusive branch of IfStatement/ConditionalExpression and around each non-fallthrough case of SwitchStatement, preventing abort-controller sources from leaking between exclusive code paths.

Create PR

Or push these changes by commenting:

@cursor push 04e563ed22
Preview (04e563ed22)
diff --git a/packages/octane/src/compiler/strong-mode.js b/packages/octane/src/compiler/strong-mode.js
--- a/packages/octane/src/compiler/strong-mode.js
+++ b/packages/octane/src/compiler/strong-mode.js
@@ -4148,15 +4148,18 @@
 				const branchPhase = phaseAfter(node.test, phase);
 				const branches = conditionalExpressionBranches(node, scope);
 				const guards = currentEffect === null ? undefined : effectPolicy.saveGuards();
+				const savedFlow = currentEffect === null ? undefined : effectPolicy.saveFlow();
 				if ((branches & 1) !== 0) {
 					if (guards !== undefined) effectPolicy.guard(node.test, true);
 					visit(node.consequent, scope, branchPhase);
 					if (guards !== undefined) effectPolicy.restoreGuards(guards);
+					if (savedFlow !== undefined) effectPolicy.restoreFlow(savedFlow);
 				}
 				if ((branches & 2) !== 0) {
 					if (guards !== undefined) effectPolicy.guard(node.test, false);
 					visit(node.alternate, scope, branchPhase);
 					if (guards !== undefined) effectPolicy.restoreGuards(guards);
+					if (savedFlow !== undefined) effectPolicy.restoreFlow(savedFlow);
 				}
 				return;
 			}
@@ -4305,11 +4308,15 @@
 
 				const fallbackPhase = searchPhase;
 				searchPhase = initialPhase;
+				const savedFlow = currentEffect === null ? undefined : effectPolicy.saveFlow();
 				let fallthroughPhase = null;
 				for (const branch of branches) {
 					if (currentFunctionIsAsync && searchPhase !== 'deferred' && alwaysAwaits(branch.test)) {
 						searchPhase = 'deferred';
 					}
+					if (savedFlow !== undefined && fallthroughPhase === null) {
+						effectPolicy.restoreFlow(savedFlow);
+					}
 					const matchingPhase = branch.test == null ? fallbackPhase : searchPhase;
 					const branchPhase =
 						matchingPhase === 'deferred' &&
@@ -4326,6 +4333,7 @@
 							? null
 							: executionPhase;
 				}
+				if (savedFlow !== undefined) effectPolicy.restoreFlow(savedFlow);
 				return;
 			}
 			case 'VariableDeclaration': {

diff --git a/packages/octane/tests/compiler/strong-effects.test.ts b/packages/octane/tests/compiler/strong-effects.test.ts
--- a/packages/octane/tests/compiler/strong-effects.test.ts
+++ b/packages/octane/tests/compiler/strong-effects.test.ts
@@ -528,6 +528,46 @@
 			),
 		).not.toThrow();
 	});
+
+	it('does not leak abort sources from one if-branch into the other', () => {
+		const source = component(
+			`const [data, setData] = useState(null);
+useEffect(() => {
+  const controller = new AbortController();
+  (async () => {
+    if (props.useSignal) {
+      const r = await fetch('/api', { signal: controller.signal });
+      setData(await r.json());
+    } else {
+      setData(await api.get(props.id));
+    }
+  })();
+  return () => controller.abort();
+});`,
+		).replace("from 'octane';", "from 'octane';\nimport { api } from './api';");
+		rejects(source, FETCH);
+	});
+
+	it('does not leak abort sources from one switch-case into another', () => {
+		const source = component(
+			`const [data, setData] = useState(null);
+useEffect(() => {
+  const controller = new AbortController();
+  (async () => {
+    switch (props.mode) {
+      case 'signal':
+        setData(await fetch('/api', { signal: controller.signal }));
+        break;
+      default:
+        setData(await api.get(props.id));
+        break;
+    }
+  })();
+  return () => controller.abort();
+});`,
+		).replace("from 'octane';", "from 'octane';\nimport { api } from './api';");
+		rejects(source, FETCH);
+	});
 });
 
 describe('Strong zero-delay effect updates', () => {

You can send follow-ups to the cloud agent here.

trueadm and others added 3 commits October 1, 2026 09:33
…y awaits

Two review findings on the Strong zero-delay and custom-hook checks:

- mergeShapes required every return of a custom hook to yield the same
  shape object, but each `return [value, setValue]` or object literal builds
  a fresh shape, so a hook returning its tuple on two paths lost updater
  provenance. Array and object shapes now merge element by element, keeping
  each value that every path returns.
- Zero-delay awaits only matched a direct Promise.resolve/reject call.
  Sequence, conditional, and logical forms now recurse, and an await result
  counts as a non-promise, so `await (await null)`,
  `await (0, Promise.resolve())`, and `await (flag ? Promise.resolve() : null)`
  stay in effect setup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… path

Review finding: abort controllers found on one await stayed on the flow for
later awaits that carried no signal, and if/switch visits never restored the
flow, so an abort belonging to one request could count as cleanup for a
different update, including one on an exclusive branch.

Each yield now replaces the abort proof with its own request's controllers,
including a request whose result it reads (`(await fetch(url, { signal })).json()`).
Branches, logical operands, switch cases, try/catch, and loops join their
flows: only controllers shared by every path survive, and a join after any
yield starts a new segment. Loop bodies that yield start from a fresh
segment because a later iteration follows the previous iteration's yield.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

trueadm and others added 3 commits October 1, 2026 09:45
Review finding: an await result counts as settled, so the outer await in
`await (null ?? await load())` or `await (true ? await load() : null)` is
zero-delay, and the yield belongs to the inner await. alwaysAwaits only
inspected the left operand of a logical expression and required both
branches of a conditional, so it missed that inner await and a later update
was rejected as effect setup. A literal left operand or literal test now
selects the operand that always runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… loops normally

Review findings on the flow joins added for Strong abort proofs:

- A catch handler that always returns or throws no longer joins into the
  code after the try, so the try block's proof survives.
- A switch case ending in continue leaves the enclosing loop and no longer
  joins the flow after the switch.
- A loop test that always yields runs right before every iteration, so its
  proof is kept instead of starting the body from a fresh segment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Finally inherits try-only abort proof
    • Moved the finally visit before the next-statement narrowing by computing the conservative join of try and catch flows for the finalizer, then narrowing to afterBlock only afterward, so finally no longer inherits the try-only abort proof when catch exits.

Create PR

Or push these changes by commenting:

@cursor push 9af25b4a6f
Preview (9af25b4a6f)
diff --git a/packages/octane/src/compiler/strong-mode.js b/packages/octane/src/compiler/strong-mode.js
--- a/packages/octane/src/compiler/strong-mode.js
+++ b/packages/octane/src/compiler/strong-mode.js
@@ -4354,17 +4354,19 @@
 					const afterBlock = effectPolicy.saveFlow();
 					effectPolicy.restoreFlow(effectPolicy.joinFlow(before, afterBlock));
 					visit(node.handler, scope, phase);
+					// `finally` runs on every completion path; visit it with the
+					// conservative join before narrowing for the next statement.
+					const afterHandler = effectPolicy.saveFlow();
+					effectPolicy.restoreFlow(effectPolicy.joinFlow(afterBlock, afterHandler));
+					visit(node.finalizer, scope, phase);
 					// Only a path that completes normally reaches the next statement.
 					const blockExits = branchAlwaysExits(node.block);
 					const handlerExits = branchAlwaysExits(node.handler.body);
 					if (handlerExits && !blockExits) effectPolicy.restoreFlow(afterBlock);
-					else if (blockExits === handlerExits) {
-						effectPolicy.restoreFlow(effectPolicy.joinFlow(afterBlock, effectPolicy.saveFlow()));
-					}
 				} else {
 					visit(node.handler, scope, phase);
+					visit(node.finalizer, scope, phase);
 				}
-				visit(node.finalizer, scope, phase);
 				return;
 			}
 			case 'JSXSwitchExpression': {

diff --git a/packages/octane/tests/compiler/strong-effects.test.ts b/packages/octane/tests/compiler/strong-effects.test.ts
--- a/packages/octane/tests/compiler/strong-effects.test.ts
+++ b/packages/octane/tests/compiler/strong-effects.test.ts
@@ -228,6 +228,10 @@
 			'a catch handler after an unsigned request',
 			`try { await fetch('/a', { signal }); } catch { await api.get(props.id); } setData(1);`,
 		],
+		[
+			'a finally block when catch exits',
+			`await api.warm(); try { await fetch('/a', { signal }); } catch { return; } finally { setData(1); }`,
+		],
 	])('rejects an abort proof that does not cover %s', (_label, body) => {
 		rejects(app(aborted(body)), FETCH);
 	});

You can send follow-ups to the cloud agent here.

@cursor

This comment has been minimized.

trueadm and others added 3 commits October 1, 2026 10:24
… Strong abort proofs

Review findings on the Strong abort-proof flow:

- When a catch handler always exits, the code after the try keeps the try
  block's proof, but the finally block also runs after the handler (or a
  throw part way through either), so it now starts from the joined flow.
  Code after the finally keeps the normal-completion proof unless finally
  yields.
- Awaiting or chaining a conditional, sequence, or logical request, such as
  `await (fast ? fetch(a, { signal }) : fetch(b, { signal }))`, now keeps
  the controllers every possible request carries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 1, 2026 09:27
Resolve conflicts with the Strong state checks (#1497): keep both the
effect and state policies, visit non-zero-delay synchronous callbacks
in the event phase, and render the state in effect fixtures so they
are not write-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…ong-effect-async-cleanup

Keep fetch identity for the Strong updater-purity check from #1497,
drop the removed fetch-control save in pure callbacks, keep the
instance-field ownership toggle with the new event phase, and render
the state written by async-effect fixtures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

trueadm and others added 3 commits October 1, 2026 10:59
…eck every await path

- Derive state identity per call for setters, tuples, and returned
  callbacks, including nested hooks; values passed in keep the caller's
  identity. Forward nested call shapes and useTransition tuples.
- Keep updater purity checks on custom-hook state.
- An await ends synchronous setup only when every path waits: a branch
  that resumes in a microtask, a literal-decided operand, or a bare
  undefined operand is decided like `if (c) await work;`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A request helper that reads `controller.signal` and a cleanup helper
that calls `controller.abort()` now map the parameter to the argument
of each call, through stable aliases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Export vars treated as uninitialized
    • Added ExportNamedDeclaration/ExportDefaultDeclaration unwrapping in the mark() helper so exported var declarations at module scope are properly entered into varRegions and recognized as initialized.

Create PR

Or push these changes by commenting:

@cursor push 7bfa0c7d05
Preview (7bfa0c7d05)
diff --git a/packages/octane/src/compiler/strong-effects.js b/packages/octane/src/compiler/strong-effects.js
--- a/packages/octane/src/compiler/strong-effects.js
+++ b/packages/octane/src/compiler/strong-effects.js
@@ -284,6 +284,11 @@
 		if (varRegions === null) {
 			varRegions = new Map();
 			const mark = (declaration, start, end) => {
+				if (
+					declaration?.type === 'ExportNamedDeclaration' ||
+					declaration?.type === 'ExportDefaultDeclaration'
+				)
+					declaration = declaration.declaration;
 				if (declaration?.type !== 'VariableDeclaration' || declaration.kind !== 'var') return;
 				for (const decl of declaration.declarations ?? []) {
 					varRegions.set(decl, [start ?? decl.end, end]);

You can send follow-ups to the cloud agent here.

@cursor

This comment has been minimized.

trueadm and others added 5 commits October 1, 2026 12:27
…effects

`export var` wraps the declaration in ExportNamedDeclaration, so it
missed the module-wide region of a bare module `var`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the custom-hook return collector and per-call state owners around
main's visitSynchronousCall, which runs helpers called from an Effect
Event with current values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ong stale-update fixture

`load().then(() => tick())` updates state after work the effect started,
which OCTANE_STRONG_EFFECT_DATA_FETCH requires cleanup to cancel or
ignore. Guard it with a cleanup flag so the fixture keeps testing only
stale-update freshness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

trueadm and others added 2 commits October 1, 2026 13:21
… Strong effects

- A stored same-module hook result keeps its returned array or object, so
  `thing[1](x)`, `thing.setValue(x)`, aliases of those members, and a
  stored transition start are tracked.
- `const { queueMicrotask } = window` names the global like
  `window.queueMicrotask`, so destructured zero-delay APIs are checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 4 total unresolved issues (including 3 from previous reviews).

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Aliased stored hook results lose members
    • Added returned-array and returned-object to both the const-alias copy list and the expressionBinding forwarding list so member accesses on aliases and through helpers are correctly recognized.

Create PR

Or push these changes by commenting:

@cursor push b5ee96c05c
Preview (b5ee96c05c)
diff --git a/packages/octane/src/compiler/strong-mode.js b/packages/octane/src/compiler/strong-mode.js
--- a/packages/octane/src/compiler/strong-mode.js
+++ b/packages/octane/src/compiler/strong-mode.js
@@ -2664,7 +2664,9 @@
 					value?.kind === 'linked-key' ||
 					value?.kind === 'constant' ||
 					value?.kind === 'transition-start' ||
-					value?.kind === 'transition-tuple'
+					value?.kind === 'transition-tuple' ||
+					value?.kind === 'returned-array' ||
+					value?.kind === 'returned-object'
 				) {
 					target.bindings.set(declaration.id.name, value);
 				} else if (value == null && initial.name === 'undefined') {
@@ -3622,7 +3624,9 @@
 				binding?.kind === 'state-tuple' ||
 				binding?.kind === 'constant' ||
 				binding?.kind === 'linked-key' ||
-				binding?.kind === 'transition-start'
+				binding?.kind === 'transition-start' ||
+				binding?.kind === 'returned-array' ||
+				binding?.kind === 'returned-object'
 			) {
 				return binding;
 			}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 1b9b0de. Configure here.

trueadm and others added 3 commits October 1, 2026 13:29
…ing early

- A falsy left operand of `&&` is the awaited value and is never a
  thenable, so `await (cond && work)` and `Promise.resolve(cond && p)`
  may resume before paint.
- Aliases of a stored hook result, and a stored result passed to a local
  helper, keep its returned array or object.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…roofs

- A `break` or `continue` nested in a branch now contributes its flow
  to the switch or loop it leaves, so an exit after an unsigned request
  is no longer hidden by a later signed one.
- A literal test or left operand selects the request whose signal
  protects the result, as in `await (null ?? fetch(url, { signal }))`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cursor

cursor Bot commented Oct 1, 2026

Copy link
Copy Markdown

Bugbot Autofix prepared fixes for all 3 issues found in the latest run.

  • ✅ Fixed: AND-await treated as always waiting
    • Fixed awaitYields to return false for && (falsy short-circuit is never thenable) and maySettle to return true for && when the left operand is unknown.
  • ✅ Fixed: Switch breaks drop unsigned paths
    • Added a switchBreakFlows collector that joinBranchFlows pushes break-exit flows to when discarding them, and the switch handler merges those flows into exits.
  • ✅ Fixed: Abort proof ignores static operands
    • requestControllers now consults selected() before intersecting both arms, so a statically dead literal arm no longer drops the live request's controller.

Create PR

Or push these changes by commenting:

@cursor push 6b1473d37e
Preview (6b1473d37e)
diff --git a/packages/octane/src/compiler/strong-effects.js b/packages/octane/src/compiler/strong-effects.js
--- a/packages/octane/src/compiler/strong-effects.js
+++ b/packages/octane/src/compiler/strong-effects.js
@@ -265,6 +265,8 @@
 				return maySettle(node.expressions?.at(-1), depth);
 			case 'ConditionalExpression':
 			case 'LogicalExpression':
+				// The && short-circuit value is falsy and never thenable.
+				if (node.operator === '&&' && !selected(node)) return true;
 				return someResult(node, maySettle, depth);
 			case 'CallExpression':
 				return settledPromise(node);
@@ -450,15 +452,19 @@
 			case 'SequenceExpression':
 				return requestControllers(node.expressions?.at(-1), depth + 1);
 			case 'ConditionalExpression':
-				return sharedControllers(
-					requestControllers(node.consequent, depth + 1),
-					requestControllers(node.alternate, depth + 1),
-				);
-			case 'LogicalExpression':
-				return sharedControllers(
-					requestControllers(node.left, depth + 1),
-					requestControllers(node.right, depth + 1),
-				);
+			case 'LogicalExpression': {
+				const only = selected(node);
+				if (only !== null) return requestControllers(only, depth + 1);
+				return node.type === 'ConditionalExpression'
+					? sharedControllers(
+							requestControllers(node.consequent, depth + 1),
+							requestControllers(node.alternate, depth + 1),
+						)
+					: sharedControllers(
+							requestControllers(node.left, depth + 1),
+							requestControllers(node.right, depth + 1),
+						);
+			}
 			case 'Identifier': {
 				const init = stableInitOf(node);
 				return init === null ? null : requestControllers(init, depth + 1);

diff --git a/packages/octane/src/compiler/strong-mode.js b/packages/octane/src/compiler/strong-mode.js
--- a/packages/octane/src/compiler/strong-mode.js
+++ b/packages/octane/src/compiler/strong-mode.js
@@ -1436,6 +1436,7 @@
 	const stateOwners = [];
 	let returnCollector = null;
 	let renderOwner = null;
+	let switchBreakFlows = null;
 	let currentEffect = null;
 	let currentFunction = null;
 	let collectEffectReads = true;
@@ -1955,9 +1956,12 @@
 		if (node?.type === 'ConditionalExpression' || node?.type === 'LogicalExpression') {
 			const only = effectPolicy.selected(node);
 			if (only !== null) return awaitYields(only);
-			return node.type === 'ConditionalExpression'
-				? awaitYields(node.consequent) && awaitYields(node.alternate)
-				: awaitYields(node.left) && awaitYields(node.right);
+			if (node.type === 'ConditionalExpression') {
+				return awaitYields(node.consequent) && awaitYields(node.alternate);
+			}
+			// The && short-circuit value is falsy and never thenable.
+			if (node.operator === '&&') return false;
+			return awaitYields(node.left) && awaitYields(node.right);
 		}
 		if (node?.type === 'SequenceExpression') return awaitYields(node.expressions?.at(-1));
 		return !effectPolicy.zeroDelayAwait(node);
@@ -3875,7 +3879,15 @@
 		if (node.type === 'IfStatement') {
 			const consequentExits = branchAlwaysExits(node.consequent);
 			const alternateExits = node.alternate != null && branchAlwaysExits(node.alternate);
-			if (consequentExits !== alternateExits) return consequentExits ? alternate : consequent;
+			if (consequentExits !== alternateExits) {
+				if (switchBreakFlows !== null) {
+					const exitBranch = consequentExits ? node.consequent : node.alternate;
+					if (statementCompletions(exitBranch).has('break:')) {
+						switchBreakFlows.push(consequentExits ? consequent : alternate);
+					}
+				}
+				return consequentExits ? alternate : consequent;
+			}
 		}
 		return effectPolicy.joinFlow(consequent, alternate);
 	}
@@ -4768,6 +4780,8 @@
 				// Each case starts from the switch, or also from the case falling into it.
 				const before = currentEffect === null ? undefined : effectPolicy.saveFlow();
 				const exits = [];
+				const savedSwitchBreakFlows = switchBreakFlows;
+				switchBreakFlows = before !== undefined ? [] : null;
 				for (const branch of branches) {
 					if (before !== undefined) {
 						effectPolicy.restoreFlow(
@@ -4805,6 +4819,10 @@
 						exits.push(effectPolicy.saveFlow());
 					}
 				}
+				if (switchBreakFlows !== null) {
+					for (const flow of switchBreakFlows) exits.push(flow);
+				}
+				switchBreakFlows = savedSwitchBreakFlows;
 				if (before !== undefined) {
 					if (!branches.some((branch) => branch.test == null)) exits.push(before);
 					if (exits.length !== 0) effectPolicy.restoreFlow(exits.reduce(effectPolicy.joinFlow));

You can send follow-ups to the cloud agent here.

trueadm and others added 2 commits October 1, 2026 18:23
A `continue` reaches the loop's update and test rather than leaving the
loop, so its flow joins the exit only when the test (or a for update)
does not await. A test that always awaits runs again before every
normal exit, so the loop exits with that test's flow plus any breaks.
Labeled jumps now go to the loop or switch they name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A labeled `continue outer` or `break outer` skips the switches and loops
between it and its label, so it no longer joins the flow after them. A
labeled block is now a jump target too, so `break done` joins the flow
after `done: { … }`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 1c44df5 into main Oct 1, 2026
29 checks passed
@trueadm
trueadm deleted the feat/strong-effect-async-cleanup branch October 1, 2026 18:17
trueadm added a commit that referenced this pull request Oct 1, 2026
#1482 landed on main as a squash that contains this branch's changes in
their latest form, so every conflict resolves to main's side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 1, 2026
#1482 landed on main as a squash of the branch this one already
contains, so every conflict resolves to this branch's side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 1, 2026
#1482 landed on main as a squash of the branch this one already
contains, so every conflict resolves to this branch's side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 1, 2026
Brings in #1482 (Strong effect cleanup must cancel or ignore async state
updates; zero-delay and transition updates count as effect setup). Keeps both
sides of strong-mode.js: the render policy and the new effect policy.

#1482 rewords OCTANE_STRONG_EFFECT_STATE_UPDATE and
OCTANE_STRONG_EFFECT_DATA_FETCH, so the derived-name, save-counter, and
user-fetch prompts now quote the current errors. It also closes seven recorded
workarounds: startTransition, queueMicrotask, Promise.resolve().then, a
zero-delay setTimeout, an async IIFE, the empty fake cleanup, and the non-fetch
API client (22 → 15 compiler gaps). The AbortController alternative still
passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 1, 2026
…resource-leaks

Both branches merged main's #1482 squash separately, so the merge had two
bases. This branch already contains #1483's changes, so conflicts keep
this side; the only new content is main's tiptap fix (#1502).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant