Skip to content

feat: write renderer and main traces with crashreporter#2003

Merged
jonathanlab merged 2 commits into
mainfrom
05-04-feat_write_renderer_and_main_traces_with_crashreporter
May 4, 2026
Merged

feat: write renderer and main traces with crashreporter#2003
jonathanlab merged 2 commits into
mainfrom
05-04-feat_write_renderer_and_main_traces_with_crashreporter

Conversation

@jonathanlab
Copy link
Copy Markdown
Contributor

Problem

Changes

How did you test this?

Publish to changelog?

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jonathanlab jonathanlab marked this pull request as ready for review May 4, 2026 13:27
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 4, 2026

Security Review

  • Crash primitives exposed in production (apps/code/src/main/preload.ts): window.__posthogCodeTest.crash() / window.__posthogCodeTest.abort() are registered via contextBridge.exposeInMainWorld unconditionally, making them available on window in production builds. Any XSS or renderer navigation to untrusted content can invoke these to crash the renderer or main process. Guard behind POSTHOG_CODE_IS_DEV.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/main/preload.ts:8-15
**`__posthogCodeTest` exposed in production builds**

`contextBridge.exposeInMainWorld` here runs unconditionally, so `window.__posthogCodeTest.crash()` and `window.__posthogCodeTest.abort()` are callable from any renderer page — including production. Any XSS or accidental navigation to untrusted content could invoke these to deliberately crash the renderer or main process. The env variable `process.env.POSTHOG_CODE_IS_DEV` is already set in `bootstrap.ts` and is accessible from the preload context.

```suggestion
if (process.env.POSTHOG_CODE_IS_DEV === "true") {
  contextBridge.exposeInMainWorld("__posthogCodeTest", {
    crash: () => {
      process.crash();
    },
    abort: () => {
      process.abort();
    },
  });
}
```

### Issue 2 of 2
apps/code/src/main/index.ts:60-82
**No retry limit on crash recovery — potential infinite reload loop**

If the renderer crashes deterministically on load (e.g., a startup bug, persistent OOM, or bad state in local storage), the `render-process-gone` handler will trigger, reload the page, which crashes again, and repeat indefinitely. Adding a small counter with a maximum attempt threshold (e.g., 3 retries within a 30-second window) would avoid spinning the process in a tight crash/reload cycle.

Reviews (1): Last reviewed commit: "feat: write renderer and main traces wit..." | Re-trigger Greptile

Comment thread apps/code/src/main/preload.ts Outdated
Comment thread apps/code/src/main/index.ts
@jonathanlab jonathanlab added the Create Release This will trigger a new release label May 4, 2026
…o 05-04-feat_write_renderer_and_main_traces_with_crashreporter
@jonathanlab jonathanlab merged commit 022b708 into main May 4, 2026
16 checks passed
@jonathanlab jonathanlab deleted the 05-04-feat_write_renderer_and_main_traces_with_crashreporter branch May 4, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants