You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An extension can retain an old native messaging port after startup fails or it disconnects. That closed port still holds every message queued during startup, even though none can ever be sent. Clear the queue on both terminal paths so keeping the port no longer keeps its abandoned payloads.
Change
Add entry.queued.length = 0 immediately after the transition to closed in the shared endPort() path and explicit disconnect(). Reuse the existing lifecycle, map removal, event delivery and late-connect cleanup. Healthy startup still sends every queued message once, in order.
This is a two-line cleanup fix in the installer used by both extension pages and service workers, introduced with native messaging in #30940. It does not bound startup admission or change the native-host wire.
Measurements
48 fresh serial forced-GC probes exercise the actual production installer, transformed and serialized into a real V8 VM, across page/worker contexts, four startup outcomes and 1/10/100 messages. Each message contains 128 KiB of unique payload; the largest serialized workload is 13,118,990 bytes.
At 100 page messages, after the connect reply settles and while the returned closed port remains retained:
Startup outcome
Baseline heap delta
Fixed heap delta
Published messages, both
Explicit early disconnect
13,208,056 B
86,968 B
0
Failed connect
13,211,400 B
90,344 B
0
Early host disconnect
13,211,400 B
90,344 B
0
Healthy startup, then disconnect
164,592 B
164,632 B
100
Eight heap snapshots independently establish the retaining path: returned port → postMessage closure → entry → queued JSON strings. At ten messages, each aborted baseline retains ten tagged strings / 1,312,000 self bytes; the fixed and healthy cases retain zero. Releasing the port makes it collectible in all 48 rows, including baseline, which controls for harness retention.
Validation
External retained-string regression: baseline three failures and one healthy pass; fixed four passes.
All 48 behavior probes preserve FIFO byte lengths/hashes, exactly-once healthy delivery, zero abandoned publication, late-event rejection, idempotent disconnect and callback/lastError behavior.
Existing installer tests pass 7/7 on both versions. Final focused preload/main-world/native-port/host/framing suites pass 42 tests across five files.
Node typecheck, explicit formatting, diff check and all nine changed-code quality groups pass. No precommit-hook claim; the standalone clone did not prepare Husky.
All eight source/trace inputs match the measured proposal and pinned baseline. The committed production file has the exact measured SHA256.
Required ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2 passed on the author head 9c4f7ad (13/13 checks, 194.0s vs main bbd635e). After a clean rebase onto main 58f9523 it passed again on 3c31f8b (14/14 checks, 166.8s).
Scope and evidence
Executed on Linux Node 26.8.1 / V8 14.6. This is actual-installer heap evidence with controlled bridge replies/events, not a real native host, Electron contextBridge installation, full Orca flow, whole-app heap/RSS, CPU or latency measurement. Worker contexts have forced-GC evidence; snapshots cover page contexts. Cleanup is platform-neutral; macOS and Windows were not executed. No remote protocol, mobile behavior or workspace assumptions change.
Independent tmpfs author clone, frozen-lock dependencies and verified pinned Bun 1.4.4. Evidence: /home/neil/.local/state/orca-electron-audit/native-messaging-startup-queue-candidate/report.md, source manifests, forced-GC rows and heap snapshots, baseline/fixed logs, author verification and implementation.bundle. The original sealed read-only archive is preserved.
No actionable comments were generated in the recent review.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 74a183f9-3364-4697-97bf-26d2c3b7c88e
Commits
Reviewing files that changed from the base of the PR and between 828fe5f and 3c31f8b.
Files selected for processing: 1
src/preload/browser-extension-native-messaging.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Walkthrough
endPort and local disconnect now clear queued messages when they close a port.
Priority: Low
Merge Risk: Minimal · up to 3c31f
The change releases queued startup messages without altering healthy FIFO delivery or existing disconnect behavior.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: releasing abandoned native messaging startup payloads.
Description check
The description provides detailed scope, rationale, implementation details, measurements, testing, and limitations. It does not include an explicit Linked Issue entry, Visual Proof entry with N/A, or …
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description provides detailed scope, rationale, implementation details, measurements, testing, and limitations. It does not include an explicit Linked Issue entry, Visual Proof entry with N/A, or the template checklist and review sections.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
An extension can retain an old native messaging port after startup fails or it disconnects. That closed port still holds every message queued during startup, even though none can ever be sent. Clear the queue on both terminal paths so keeping the port no longer keeps its abandoned payloads.
Change
Add
entry.queued.length = 0immediately after the transition toclosedin the sharedendPort()path and explicitdisconnect(). Reuse the existing lifecycle, map removal, event delivery and late-connect cleanup. Healthy startup still sends every queued message once, in order.This is a two-line cleanup fix in the installer used by both extension pages and service workers, introduced with native messaging in #30940. It does not bound startup admission or change the native-host wire.
Measurements
48 fresh serial forced-GC probes exercise the actual production installer, transformed and serialized into a real V8 VM, across page/worker contexts, four startup outcomes and 1/10/100 messages. Each message contains 128 KiB of unique payload; the largest serialized workload is 13,118,990 bytes.
At 100 page messages, after the connect reply settles and while the returned closed port remains retained:
Eight heap snapshots independently establish the retaining path: returned port → postMessage closure → entry → queued JSON strings. At ten messages, each aborted baseline retains ten tagged strings / 1,312,000 self bytes; the fixed and healthy cases retain zero. Releasing the port makes it collectible in all 48 rows, including baseline, which controls for harness retention.
Validation
ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2passed on the author head 9c4f7ad (13/13 checks, 194.0s vs main bbd635e). After a clean rebase onto main 58f9523 it passed again on 3c31f8b (14/14 checks, 166.8s).Scope and evidence
Executed on Linux Node 26.8.1 / V8 14.6. This is actual-installer heap evidence with controlled bridge replies/events, not a real native host, Electron contextBridge installation, full Orca flow, whole-app heap/RSS, CPU or latency measurement. Worker contexts have forced-GC evidence; snapshots cover page contexts. Cleanup is platform-neutral; macOS and Windows were not executed. No remote protocol, mobile behavior or workspace assumptions change.
Independent tmpfs author clone, frozen-lock dependencies and verified pinned Bun 1.4.4. Evidence:
/home/neil/.local/state/orca-electron-audit/native-messaging-startup-queue-candidate/report.md, source manifests, forced-GC rows and heap snapshots, baseline/fixed logs, author verification andimplementation.bundle. The original sealed read-only archive is preserved.