Skip to content

fix(raycast): guard registry microtask teardown#598

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

fix(raycast): guard registry microtask teardown#598
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-wave4-registry-microtask-lifecycle

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added mounted lifecycle guards around queueMicrotask-scheduled registry updates for collected actions, list items, grid items, and MenuBarExtra registrations.
  • Cleared per-component registry/cache refs on teardown and ignored late registry API calls after unmount so stale registration closures are not retained by dead registries.
  • Added a focused Node harness for registry microtask lifecycle behavior across actions, list, grid, and menubar surfaces.

Why

Registry updates were coalesced through queueMicrotask, but an already-scheduled microtask could outlive the owning React component and call setState after unmount. The guards preserve the existing batching, ordering, payload semantics, and dirty-check behavior while suppressing post-unmount updates.

Compatibility impact

No public Raycast API behavior changes are intended. Mounted registry semantics, action/list/grid/menu payload shapes, ordering, batching, and existing dirty-check decisions are unchanged.

How tested

  • node --test scripts/test-registry-microtask-lifecycle.mjs
  • node --test scripts/test-registry-dirty-checks.mjs
  • node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js run typecheck:renderer
  • Codex LSP diagnostics on the four touched runtime files: no diagnostics found

Performance evidence

  • Lifecycle harness legacy reproduction: actions/list/grid/menubar each queued 1 pending callback and produced 1 post-unmount setState call.
  • Lifecycle harness fixed behavior: actions/list/grid/menubar each produced 0 setState calls and 0 post-unmount setState calls after unmount.
  • Dirty-check harness preserved no full-registry walks on optimized paths. Example 5000-item run: list single recreated equivalent before 5000 fullSnapshotItemWalks vs after 0 fullSnapshotItemWalks and 1 itemSignatureBuild; grid single recreated equivalent before 5000 fullSnapshotItemWalks vs after 0 fullSnapshotItemWalks and 1 itemSignatureBuild.

Stack validation

Started from codex/perf-wave3-integration-stack-20260704 at 206eab8. Pushed implementation branch codex/perf-wave4-registry-microtask-lifecycle from commit 17fb535.

Replaces

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

…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