Repository navigation
feat(electron): instrument trusted utility processes - #5718
marandaneto wants to merge 23 commits into
Conversation
…y-process # Conflicts: # packages/electron/README.md # packages/electron/package.json # packages/electron/src/__tests__/main.test.ts # packages/electron/src/main/index.ts # packages/electron/tsdown.config.mts
Coherence📄 0 spec file errors · ⛔ 0 broken rules · 🚪 2 unchecked inputs · 🐛 0 bugs that came back What is Coherence?Coherence compares the code with its spec files ( This check read 44 parts of the code and 7 rules. Note These findings do not make this check fail. None of these findings are in files that this pull request changes. You do not need to fix them in this pull request. 🚪 Unchecked inputs (2)
What this means and how to fix itInput from outside this code comes in at these places. The spec does not say what checks that input. 10 more places were already like this when Coherence was added. This list does not show them. To close one of these, find the place by its name in the
To get the line to add, run |
Node SDK acceptance v2Commit: 96a9d2d Capture v0✅ 83 passed / ❌ 4 non-passing / Drill-down: run artifacts → ❌ server_snapshot_payload_false — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_zero — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_null — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ migration/yaml-parity-v1/remote-flags-v1.feature::Omitted GeoIP settings default to enabled in flag requests — failed_assertionFlags field differs Code: Failed step: migration/yaml-parity-v1/remote-flags-v1.feature:134 the first flags request field "geoip_disable" should equal JSON false Operation: Field: Expected: false Actual value: true Harness exit: 1; report validation exit: 1. Capture v1✅ 148 passed / ❌ 4 non-passing / Drill-down: run artifacts → ❌ server_snapshot_payload_false — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_zero — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ server_snapshot_payload_null — failed_assertionExpected native data result Code: Failed step: acceptance/public/evaluate-flags.feature:868 the public snapshot outcomes should have these semantics: ❌ migration/yaml-parity-v1/remote-flags-v1.feature::Omitted GeoIP settings default to enabled in flag requests — failed_assertionFlags field differs Code: Failed step: migration/yaml-parity-v1/remote-flags-v1.feature:134 the first flags request field "geoip_disable" should equal JSON false Operation: Field: Expected: false Actual value: true Harness exit: 1; report validation exit: 1. |
SDK performance: posthog-nodeBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
|
|
✅ Security review complete — No findings above the confidence threshold, in 7 min. Add the |
There was a problem hiding this comment.
PostHog Review · Standard · reviewed e2bd0c4: 4 Should fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
|
Changeset note: these warnings are expected. Electron is intentionally private across the implementation PRs (#5696–#5719), is in the Changesets |
dustinbyrne
left a comment
There was a problem hiding this comment.
Three earlier transport issues are resolved. The slow-flush terminal disconnect remains unresolved; please settle its recovery/lifecycle behavior before approval.
AI-assisted review.
Problem
The Electron alpha needs coordinated instrumentation in helper processes.
Changes
Stacked on #5717 (
feat/electron-react-bindings). Review and merge in dependency order. Keep the stack draft until human review and release gates are satisfied.Add
@posthog/electron/utilityand explicit main registration of a trustedutilityProcess.fork()result. Utility clients share main identity, consent, sessions, flags and delivery instead of creating another SDK owner.Validate connection tokens, message size, rate, ordering and identity generation. Assign process context in main and revoke pending work when a child exits or registration closes. Keep reloads outside the mutation lock. Utility registration has one documented client lifetime; automatic DOM/error options are not exposed there.
Validation and limits
193 unit tests, seven built checks, types/build and genuine installed-tarball utilityProcess tests passed on macOS. Tests cover protected attribution, flags, consent/reset, pending close, unexpected exit and replacement sources. Actual ordinary-Node import/manual-exception proof verifies no browser globals are required.
Optional observer definitions may be present in the reused facade, but are not installed in utility processes. Windows/Linux packaged utility validation remains pending.
Required isolated Pi autoreview was run against this branch and its immediate predecessor. Parent test-quality audit and reproduction-first fixes are recorded locally. Replay, native crash capture, surveys and product tours remain excluded.
Release info Sub-libraries affected
Libraries affected
@posthog/electron
Checklist
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi and specialist workers implemented and checked the change using local tools, Git/gh, real Electron fixtures and the prescribed isolated Pi autoreview helper. The parent verified findings against code and runtime evidence. Human review is required before merge.
Stack
Merge the implementation PRs in dependency order. Electron is private, ignored by stable Changesets and absent from the stable npm publish matrix starting in #5696; intermediate merges cannot publish it. Only #5720 removes the private flag and enables the separate protected manual alpha path. Merging #5720 still does not publish automatically.
Current CI follow-up
Windows and Linux native and genuine Forge/Builder jobs passed on Electron 41.0.2, 42.4.0 and 43.0.0. The initial macOS jobs were canceled because GitHub retired macos-14 on November 2, 2026. Both new Electron workflows now select the supported macos-15 image. Updated macOS CI is pending. Local macOS installed-package fixtures pass. Published conformance and npm readiness remain separate gates.
Final review warning about filling 100 pending utility requests was rejected after checking the real facade: requests await the prior bridge response through its promise queue, so supported fire-and-forget calls cannot fill that main-side set. Request timeout closes the bridge. Raw-protocol misuse is not a supported client path.
Merge-safety cleanup
The temporary
docs/plans/electron-sdk.mdplanning document is removed from the stack; local validation receipts remain ignored undertarget/. The built-export regression verifies actual Changesets release planning, private staging and the protected manual alpha boundary. It failed on the original stable Electron version bump and passes after cleanup. SDK runtime source is unchanged. Fresh CI results for these updated heads remain separate from historical runtime/conformance evidence.