Skip to content

Electron's two native error paths disagree on error category (330-699) #880

Description

@sanchitmonga22

Follow-up from #779 by @ayaangazali -- thanks again for that PR!

What

After #779, Electron's two native error paths report different categories for the same code range. native/proto_bridge.cpp's ProtoError carries the sdkError that rac_result_to_proto_error in core/src/foundation/rac_proto_adapters.cpp:1036-1039 built, which still only maps |100|-|329| and falls through to INTERNAL. native/addon.cpp's make_rac_error (16 call sites, e.g. :932, :3785) attaches no category at all, so those errors fall to the shared categoryForCode at bindings/electron/src/errors.ts:329, which now maps 330-699 to real categories. So code 600 (BACKEND_NOT_FOUND) is COMPONENT on one native path and INTERNAL on the other. Web has the same split depending on whether a WASM module is loaded. The other SDKs disagree too: bindings/python/runanywhere/errors.py:10-17 and bindings/kotlin/.../CppBridgeRAG.kt:254-263 each carry their own copy of the range table, and none of the three matches the TS convenience table's 18 ranges.

Why it matters

An app catching error.category can get a different answer depending on which native code path threw inside one SDK, and a different answer again across Kotlin, Python and Electron/Web/RN for the same underlying rac_result_t. The TS table's own header comment names commons' narrow mapping a known, deliberately deferred gap -- this issue is that deferred work.

Suggested approach

  • Widen commons rac_result_to_proto_category (core/src/foundation/rac_proto_adapters.cpp) to the same 18-range mapping bindings/proto-ts/src/convenience/errors_category.ts already documents as canonical.
  • Once commons matches, remove the Python and Kotlin-RAG copies so every SDK defers to one table again.
  • Optionally, have addon.cpp's make_rac_error attach sdkError the way proto_bridge.cpp's ProtoError does, so Electron's own two native paths stop disagreeing even before commons is widened.

Done when

  • Commons' range table matches the 18-range mapping for every documented idl/errors.proto code.
  • Python and Kotlin-RAG no longer carry their own copy of the range table.
  • The same rac_result_t produces the same ErrorCategory on every SDK, and on every native error path within a given SDK.

Not blocking #779. @ayaangazali, you know this code well now -- you're welcome to take this one if you're interested.

Opened with help from Claude Code and Codex.

Reviewed with help from Claude Code and Codex.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions