Repository navigation
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for actualbudget-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Express 5's app.listen passes its callback to server.once('error'), so a
failed bind (EADDRINUSE, EACCES) ran the success callback, printed
"Listening on ...", and the process exited 0 once nothing kept it alive.
Listen through a small helper that resolves on 'listening' and rejects on
'error', and return the startup promise from app.ts so the existing catch
logs the error and exits 1.
Assisted-by: ClaudeCode:claude-opus-5-5
febecbe to
a33ddca
Compare
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Promise-based server listening packages/sync-server/src/util/server-listen.ts, packages/sync-server/src/util/server-listen.test.ts |
listen returns a promise that resolves with the bound address or rejects on a server error. Tests cover bound addresses, port conflicts, and error-listener cleanup. |
Startup integration and error propagation packages/sync-server/src/app.ts, packages/sync-server/app.ts, upcoming-release-notes/sync-server-listen-error.md |
HTTP and HTTPS startup await listen before reporting the server address. The startup chain returns the app run promise, and the release note describes port-unavailable behavior. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- actualbudget/actual#9226: Introduced the
listenhelper and changed sync-server startup to use it.
Suggested reviewers: matissjanis, tim-smart
Merge Risk: 
Minimal · up to 854d8
-
Port-binding failures now cause a nonzero exit instead of reporting successful startup. No actionable merge-blocking risk was identified.
Pre-merge checks: 
4
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Resolve conflict with actualbudget#9226, which added util/server-listen. Fold this PR's error-rejecting promise into that helper so it keeps the IPv6 fallback and bound-address reporting, and drop the duplicate util/listen. Assisted-by: ClaudeCode:claude-opus-5-5
854d8d1
Description
When the sync server can't bind its port (
EADDRINUSE, orEACCESon a port below 1024), it printsListening on :::<port>...and exits with code 0. The failure looks like a clean shutdown, so Docker'srestart: unless-stoppedtreats it as success, and the real error is never shown.Root cause: Express 5's
app.listenattaches its callback toserver.once('error', ...)as well as to'listening'.run()ignored its error argument, so a failed bind ran the "started" path.run()had rejected,app.tsdiscarded that promise withvoid. The process-wideunhandledRejectionhandler only logs, so nothing would have stopped the process.src/util/listen.ts:** resolves on'listening', rejects on'error', and removes its error listener once listening.run(): creates the http/https server and awaitslistenfor both. "Listening on ..." is now printed only after a successful bind, and the Electronserver-startedmessage is sent at the same point.app.ts: returns therun()promise, so the existing.catchlogsError starting app:with the error and exits 1.Related issue(s)
N/A
Testing
src/util/listen.test.tsbefore the helper existed and confirmed it failed. It covers:EADDRINUSEwhen the port is taken (the server is not left listening);yarn workspace @actual-app/sync-server run testpassed (58 files, 700 tests), and the sync-server typecheck passed.node packages/sync-server/build/app.json it. It now prints theEADDRINUSEerror and exits 1; before the fix it printed "Listening" and exited 0. On a free port it prints "Listening on :::5198..." and keeps running.Checklist