fix: null-safe kRPC handshake error reporting #5

Merged
Arnike merged 1 commits from debug-krpc-handshake into main 2026-06-02 23:12:51 +00:00
Owner

The bridge was falling back to mock mode with a confusing
'Cannot read properties of null (reading code)' error. The actual
underlying error (ECONNREFUSED, timeout, protocol mismatch) was
being swallowed by our error handler that did (e as Error).message
on a value that was sometimes null.

Wrap the kRPC client connect() in per-step try/catch with a
formatErr() helper that handles:

  • null / undefined
  • strings
  • Error with .code (NodeJS.ErrnoException)
  • arbitrary objects (JSON.stringify fallback)

Now when the bridge can't reach kRPC you get a real error like
'kRPC RPC TCP connect to 127.0.0.1:50000 failed: code=ECONNREFUSED:
connect ECONNREFUSED 127.0.0.1:50000' instead of the cryptic
null-code message.

Also fixed the bridge's main() error handler to be null-safe.

Discovered while debugging the user's first end-to-end run on
Windows: kRPC was reachable (Test-NetConnection succeeded) but
the bridge couldn't complete the handshake. With this fix we'll
see the real failure mode on the next attempt.

The bridge was falling back to mock mode with a confusing 'Cannot read properties of null (reading code)' error. The actual underlying error (ECONNREFUSED, timeout, protocol mismatch) was being swallowed by our error handler that did `(e as Error).message` on a value that was sometimes null. Wrap the kRPC client connect() in per-step try/catch with a formatErr() helper that handles: - null / undefined - strings - Error with .code (NodeJS.ErrnoException) - arbitrary objects (JSON.stringify fallback) Now when the bridge can't reach kRPC you get a real error like 'kRPC RPC TCP connect to 127.0.0.1:50000 failed: code=ECONNREFUSED: connect ECONNREFUSED 127.0.0.1:50000' instead of the cryptic null-code message. Also fixed the bridge's main() error handler to be null-safe. Discovered while debugging the user's first end-to-end run on Windows: kRPC was reachable (Test-NetConnection succeeded) but the bridge couldn't complete the handshake. With this fix we'll see the real failure mode on the next attempt.
Arnike added 1 commit 2026-06-02 23:12:43 +00:00
fix: null-safe kRPC handshake error reporting
CI / Lint, typecheck, test, build (pull_request) Failing after 11s
a69cd14817
The bridge was falling back to mock mode with a confusing
'Cannot read properties of null (reading code)' error. The actual
underlying error (ECONNREFUSED, timeout, protocol mismatch) was
being swallowed by our error handler that did `(e as Error).message`
on a value that was sometimes null.

Wrap the kRPC client connect() in per-step try/catch with a
formatErr() helper that handles:
- null / undefined
- strings
- Error with .code (NodeJS.ErrnoException)
- arbitrary objects (JSON.stringify fallback)

Now when the bridge can't reach kRPC you get a real error like
'kRPC RPC TCP connect to 127.0.0.1:50000 failed: code=ECONNREFUSED:
connect ECONNREFUSED 127.0.0.1:50000' instead of the cryptic
null-code message.

Also fixed the bridge's main() error handler to be null-safe.

Discovered while debugging the user's first end-to-end run on
Windows: kRPC was reachable (Test-NetConnection succeeded) but
the bridge couldn't complete the handshake. With this fix we'll
see the real failure mode on the next attempt.
Arnike merged commit b09fe6fd99 into main 2026-06-02 23:12:51 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Arnike/KSP-MissionControl#5