Skip to content

fix: guard registry microtasks after unmount#595

Closed
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-wave4-registry-microtask-cleanup
Closed

fix: guard registry microtasks after unmount#595
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-wave4-registry-microtask-cleanup

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added lifecycle guards around queueMicrotask-scheduled registry publishes in Action, List, Grid, and MenuBarExtra runtime registries.
  • Pending registry callbacks are now stored in clearable refs, released on unmount, and skipped if a stale registry API schedules after unmount.
  • Added a focused node test harness that compares legacy and guarded schedulers with post-unmount setState and retained callback counters.

Why

Registry updates were coalesced through microtasks, but a component could unmount before the queued callback ran. That left the callback able to call setState after unmount and retain stale registry closures until the microtask flushed.

Compatibility impact

Public Raycast API behavior is intended to stay unchanged. Registration ordering, batching, payload semantics, and existing dirty-check behavior are preserved while suppressing only post-unmount publishes.

How tested

  • node --test scripts/test-registry-microtask-lifecycle.mjs
  • node --test scripts/test-registry-dirty-checks.mjs
  • npm run typecheck:renderer
  • Codex LSP status plus TypeScript error diagnostics on the four edited runtime files

Performance evidence

  • Lifecycle harness: legacy post-unmount path reported postUnmountSetStateCalls=1 after flush and retainedQueuedCallbacks=1 before flush; guarded path reported postUnmountSetStateCalls=0 and retainedQueuedCallbacks=0 after unmount, with mounted coalescing still producing one setState for two schedules.
  • Dirty-check harness stayed green for 5000 items and preserved zero full-registry walks in optimized list/grid paths.

Stack validation

Started from codex/perf-wave3-integration-stack-20260704 at commit 206eab8. Implementation commit: 85e6a94.

Replaces

SuperCmd perf wave 4 child implementation: Raycast runtime registry microtask lifecycle cleanup.

…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	scripts/bench-script-command-discovery.mjs
#	scripts/benchmark-file-search-delete-batch.mjs
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-file-search-delete-batch.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/file-search-index.ts
#	src/main/main.ts
…perf-wave2-integration-stack-20260704

# Conflicts:
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-extension-lifecycle-sandbox.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	.github/workflows/project-checks.yml
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…erf-wave3-integration-stack-20260704

# Conflicts:
#	package.json
#	scripts/measure-extension-bundle-cache.mjs
#	scripts/test-icon-runtime-file-icon-cache.mjs
#	src/main/extension-runner.ts
#	src/renderer/src/components/HiddenExtensionRunners.tsx
#	src/renderer/src/raycast-api/icon-runtime-render.tsx
…/perf-wave3-integration-stack-20260704

# Conflicts:
#	scripts/test-browser-search-performance.mjs
#	scripts/test-root-search-perf.mjs
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by the clean consolidated wave4 renderer/Raycast PR: #599. That branch contains this PR's covered change on current main without the inherited broad-stack noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant