Skip to content

fix: wrap HTTP_SERVER_GET_STATUS response in IpcResult envelope#57

Merged
matt1398 merged 1 commit intomatt1398:mainfrom
proxikal:fix/settings-http-server-status-ipc
Feb 22, 2026
Merged

fix: wrap HTTP_SERVER_GET_STATUS response in IpcResult envelope#57
matt1398 merged 1 commit intomatt1398:mainfrom
proxikal:fix/settings-http-server-status-ipc

Conversation

@proxikal
Copy link
Contributor

Summary

Opening the Settings page threw an unhandled promise rejection every time:

Uncaught (in promise) Error: Unknown error

Root Cause

The three HTTP server IPC handlers are inconsistent in how they return data:

Handler Response shape
HTTP_SERVER_START { success: true, data: { running, port } }
HTTP_SERVER_STOP { success: true, data: { running, port } }
HTTP_SERVER_GET_STATUS { running, port }

invokeIpcWithResult() in the preload layer expects every handler to return an IpcResult<T> envelope ({ success, data }). When success is absent it's falsy, so the function throws:

if (!result.success) {
  throw new Error(result.error ?? 'Unknown error'); // result.error also undefined → "Unknown error"
}

GeneralSection calls api.httpServer.getStatus() on mount, so the error fired immediately every time Settings opened.

Fix

Wrap the HTTP_SERVER_GET_STATUS return value in the standard IpcResult envelope, matching the other two handlers.

// Before
ipcMain.handle(HTTP_SERVER_GET_STATUS, () => {
  return { running: httpServer.isRunning(), port: httpServer.getPort() };
});

// After
ipcMain.handle(HTTP_SERVER_GET_STATUS, () => {
  return { success: true, data: { running: httpServer.isRunning(), port: httpServer.getPort() } };
});

Files Changed

File Change
src/main/index.ts Wrap HTTP_SERVER_GET_STATUS response in IpcResult envelope

Test Plan

  • Open Settings — no Unknown error in the DevTools console
  • HTTP server toggle in Settings still starts/stops correctly
  • Server status indicator reflects current state on Settings open

🤖 Generated with Claude Code

The HTTP_SERVER_GET_STATUS handler returned a raw { running, port } object
while all other HTTP server handlers (start, stop) return { success, data }.
invokeIpcWithResult() in the preload expects the IpcResult<T> envelope and
treats a missing success field as failure, throwing 'Unknown error'.

This caused an unhandled promise rejection every time the Settings page
opened, because GeneralSection calls api.httpServer.getStatus() on mount.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@proxikal
Copy link
Contributor Author

Closing to re-submit after running full quality gates (typecheck, lint, test, build).

@proxikal proxikal closed this Feb 21, 2026
@proxikal proxikal reopened this Feb 21, 2026
@proxikal
Copy link
Contributor Author

Quality gates verified before re-opening: pnpm typecheckpnpm lintpnpm test (650 tests passing) ✅ pnpm build

@matt1398 matt1398 merged commit 9c04e90 into matt1398:main Feb 22, 2026
3 checks passed
@proxikal proxikal deleted the fix/settings-http-server-status-ipc branch February 23, 2026 00:09
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.

2 participants