Skip to content

perf(runtime): cancel extension HTTP work on abort - #609

Closed
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-runtime-cancel-extension-http-20260705
Closed

perf(runtime): cancel extension HTTP work on abort#609
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-runtime-cancel-extension-http-20260705

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Exposed cancelHttpRequest(requestId) through preload and the renderer Electron API type.
  • Preserved existing httpRequest and one-argument httpDownloadBinary(url) compatibility while allowing an optional request ID for cancelable binary downloads.
  • Kept the extension fetch abort listener active through binary follow-up downloads, then removed it on every terminal path.
  • Reused the main-process http-request-cancel map for canceling Node HTTP(S) binary downloads and curl fallback processes.
  • Extended the extension fetch abort harness with a binary follow-up abort case.

Why

The renderer bridge already generated request IDs and attempted to call electronBridge.cancelHttpRequest, while main already listened for http-request-cancel. The preload/type surface did not expose that method, and binary follow-up downloads did not receive a request ID, so a fetch for binary content could outlive abort/unmount and resolve stale data after the text probe was canceled.

Compatibility impact

Raycast-compatible call shapes are preserved: existing callers can still call httpRequest(options) and httpDownloadBinary(url). The optional request ID is only used by SuperCmd extension fetch cancellation, and non-http/FormData fallback behavior is unchanged.

How tested

  • node scripts/test-extension-fetch-proxy-abort.mjs
  • node scripts/test-use-fetch-stale-runs.mjs
  • ./node_modules/.bin/tsc -p tsconfig.renderer.json --noEmit --pretty false
  • ./node_modules/.bin/tsc -p tsconfig.main.json --pretty false
  • LSP diagnostics: no errors in src/renderer/src/extension-fetch-bridge.ts, src/main/preload.ts, src/renderer/types/electron.d.ts, or src/main/main.ts.
  • npm run typecheck:renderer and npm run build:main were blocked by the local machine npm policy/parity guard, so direct tsc binaries from a temporary sibling node_modules symlink were used instead. The symlink was removed before commit.

Performance evidence

  • Before: running the updated binary abort harness against exact base SHA ac90ce403aeddab98d0a1b245afce268c48b8bfd failed because the old binary follow-up received undefined instead of the active extensionFetch:* request ID.
  • After: node scripts/test-extension-fetch-proxy-abort.mjs passes 4/4, including binary follow-up cancellation, single cancel emission, listener cleanup, and stale byte rejection.

Stack validation

  • Started from codex/perf-wave4-integrated-stack-20260705 at exact SHA ac90ce403aeddab98d0a1b245afce268c48b8bfd.
  • Working branch: codex/perf-runtime-cancel-extension-http-20260705.
  • git diff --check passed.

Replaces

None.

(cherry picked from commit 83c2a89)
(cherry picked from commit 0a7560b)
# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…launcher surfaces

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…IO stalls

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…resh overhead

# 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
…hurn

# 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
… hot paths

# Conflicts:
#	scripts/test-use-frecency-sorting.mjs
#	src/renderer/src/raycast-api/form-runtime.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/grid-runtime-items.tsx
#	src/renderer/src/raycast-api/hooks/use-frecency-sorting.ts
# Conflicts:
#	.github/workflows/project-checks.yml
#	package.json
#	scripts/file-search-perf-harness.mjs
#	scripts/test-browser-search-performance.mjs
#	scripts/test-file-search-perf-harness.mjs
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/hooks/useBrowserSearch.ts
#	src/renderer/src/raycast-api/list-runtime.tsx
…cle and media fixes

# Conflicts:
#	scripts/lib/ts-import.mjs
#	scripts/measure-extension-bundle-cache.mjs
#	src/main/commands.ts
#	src/main/extension-runner.ts
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/list-runtime-hooks.ts
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated runtime/lifecycle/media PR: #622

@JustYannicc JustYannicc closed this Jul 5, 2026
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