Skip to content

fix(raycast): guard registry microtasks after unmount - #584

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

fix(raycast): guard registry microtasks after unmount#584
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/raycast-registry-microtask-cleanup-20260704

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added mounted-state guards around queueMicrotask-scheduled registry updates for action, list, grid, and MenuBarExtra registries.
  • Added unmount cleanup for pending flags and registry/signature payload caches so stale registrations and closures are dropped after the owning runtime unmounts.
  • Added a focused node harness covering legacy versus fixed post-unmount microtask behavior.

Why

  • Registry updates are intentionally batched through queueMicrotask, but those callbacks can be delivered after the registry owner has unmounted.
  • The previous lifecycle shape could call setState after unmount and keep stale registry entries alive until the queued callback ran.

Compatibility impact

  • Public Raycast API behavior is unchanged.
  • Existing ordering, batching, action/list/grid/menu payload semantics, and dirty-check behavior are preserved; only post-unmount queued work is suppressed.

How tested

  • node --test scripts/test-registry-microtask-lifecycle.mjs
  • node --test scripts/test-registry-dirty-checks.mjs
  • npm run typecheck:renderer
  • Codex LSP diagnostics on the edited renderer files: no errors.

Performance evidence

  • New lifecycle harness: legacy simulation reports postUnmountSetStateCalls=1, pendingAfterUnmount=1, and registryEntriesAfterUnmount=1 for action/list/grid/menubar; fixed simulation reports postUnmountSetStateCalls=0, pendingAfterUnmount=0, and registryEntriesAfterUnmount=0 for all four.
  • Dirty-check harness still avoids full-registry walks on single recreated equivalent updates: list and grid both report before.fullSnapshotItemWalks=5000, after.fullSnapshotItemWalks=0, after.itemSignatureBuilds=1, and after.versionUpdates=0.

Stack validation

  • Started from codex/perf-wave3-integration-stack-20260704 at 206eab8280a2eb91a57e4e74ea6df99e45a55cb4.
  • Implementation commit: 4a1fe2c.

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