We spawn the daemon detached with its stdio discarded, so a fatal startup error was just an exit code. A denied listen() even exited 0, since the server error handler routed through shutdown(). This commit adds a reportFatalError() that writes the reason to a <sessionId>.error file, appends it to the log, and exits 3, plus a diagnostics.ts that turns the errnos behind these failures into explanations. The following commits are going to read this file. Also it fixes the log stream being created before the session directory exists.
Previously we only output "Daemon process exited unexpectedly during startup" on daemon startup failure. Now we report the reason the daemon records, which is the startup error file first, then the tail of its log. When neither exists, report what is known instead of guessing. If the daemon exited, print the command to rerun the spawn in the foreground. If it is still running and simply has not published its metadata, say that and name the pid, rather than declaring it dead and blaming the sandbox.
An unusable session directory is the one failure the daemon cannot report, since the error file it would report through lives in that directory. Check it in the client instead: stat, mkdir, and a write probe, because mkdirSync() succeeds on an existing directory that cannot be written to. Check the socket path length there too. The kernel rejects an over-long sockaddr_un with a bare EINVAL that names neither the limit nor the path. Also stop "session list" from creating the session directory just to find no sessions in it.
A dead daemon and a sandbox that forbids connect() look the same to validateSession(), and both ended in cleanupSession(). Deleting the socket file of a live daemon makes it unreachable for good, and deleting the metadata hides it from "session list" and "stop --all", leaving a process holding a profile that no command can find or stop. This patch gates cleanup on the errnos that prove nothing is listening: ENOENT, ECONNREFUSED, and ENOTSOCK. On EACCES, EPERM or ETIMEDOUT, keep the files and report the session as unreachable with its pid.
Merged
canova added a commit that referenced this pull request
Aug 10, 2026Changes: [fatadel] Create the Network track from the timeline-network schema display location (#6224) [Markus Stange] Only call `getRawFrameTableBuilderWithExistingContents` once per symbolication batch. (#6233) [fatadel] Improve discoverability of downloading a local profile (#6216) [Nazım Can Altınova] Handle the cli daemon startup failures more gracefully with better errors (#6241) [Nazım Can Altınova] Add the ability to apply source maps from the CLI (#6229) [Nazım Can Altınova] Handle Text and Log marker payloads with their marker schema (#6247) [Nazım Can Altınova] Bump the Gecko profile version to make sure that the Text and Log marker changes are picked up in the frontends (#6252) [fatadel] Deactivate a menu button as soon as its panel is dismissed (#6251) [Nazım Can Altınova] 🔃 Sync: l10n -> main (August 10, 2026) (#6253) [Nazım Can Altınova] Bump profiler-cli version to 0.8.0 (#6254) And special thanks to our localizers: de: Ger de: Michael Köhler el: George kitsoukakis en-CA: chutten en-CA: Saurabh en-GB: Ian Neal es-CL: ravmn fy-NL, nl: Fjoerfoks fr: Théo Chevalier fy-NL: Fjoerfoks ia: Melo46 it: Francesco Lodolo [:flod] nl: Fjoerfoks ru: michellemelsspam ru: Valery Ledovskoy tr: giray tr: Selim Şumlu zh-TW: Pin-guang Chen