Skip to content

Fix: Codex on Cursor - perf_metrics crash and missing SSE event prefix#235

Closed
rodrigorodriguescosta wants to merge 1 commit intodecolua:masterfrom
rodrigorodriguescosta:fix/codex-perf-metrics-sse-events
Closed

Fix: Codex on Cursor - perf_metrics crash and missing SSE event prefix#235
rodrigorodriguescosta wants to merge 1 commit intodecolua:masterfrom
rodrigorodriguescosta:fix/codex-perf-metrics-sse-events

Conversation

@rodrigorodriguescosta
Copy link
Contributor

Summary

  • Emit event: prefix for openai-responses flat objects in formatSSE so Cursor receives proper SSE events instead of raw data: lines.
  • Remove perf_metrics from usage payload regardless of value (not only when null), fixing "Cannot read properties of null (reading 'perf_metrics')".
  • Strip perf_metrics in passthrough mode in stream.js before forwarding.

Problem

When using Codex (OpenAI provider) in Cursor IDE, the UI could crash with Cannot read properties of null (reading 'perf_metrics'). The Codex API returns usage.perf_metrics: null in streamed responses; clients that access this field without null checks fail. Additionally, when source and target format are both openai-responses, the stream was emitted without event: prefix, breaking clients that rely on it.

Files changed

  • open-sse/utils/streamHelpers.jscleanUsagePayload and formatSSE (event prefix for response.* types)
  • open-sse/utils/stream.js — passthrough: strip perf_metrics from usage/response.usage

How to test

  1. Use Cursor with Override OpenAI Base URL pointing to 9router and Codex model.
  2. Send a chat completion (no image).
  3. Confirm no "perf_metrics" crash and stream completes correctly.

Fixes #223

Made with Cursor

- formatSSE: emit event: prefix for openai-responses flat objects (.type)
  so Cursor receives proper SSE events instead of raw data: lines
- cleanUsagePayload: remove perf_metrics regardless of value (not just null)
  fixing "Cannot read properties of null (reading 'perf_metrics')"
- stream.js passthrough: strip perf_metrics from usage before forwarding

Fixes decolua#223

Made-with: Cursor
@rodrigorodriguescosta rodrigorodriguescosta force-pushed the fix/codex-perf-metrics-sse-events branch from 66375bf to f9d8bab Compare March 3, 2026 13:57
@rodrigorodriguescosta
Copy link
Contributor Author

rodrigorodriguescosta commented Mar 3, 2026

this PR resolves this issue #223

@decolua decolua closed this Mar 6, 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.

Cursor with OpenAPI/Codex provider crashes UI: Cannot read properties of null (reading 'perf_metrics') — works on ClaudeCode/Antigravity

2 participants