fix(studio-desktop): probe ports with node:net, not Bun.listen#615
Open
Necmttn wants to merge 2 commits into
Open
fix(studio-desktop): probe ports with node:net, not Bun.listen#615Necmttn wants to merge 2 commits into
Necmttn wants to merge 2 commits into
Conversation
The Electron MAIN process runs under Node, not Bun, so `Bun` is `undefined`
there. `AxDaemonArbitration.portFree` used `Bun.listen`, so the bind probe threw
on every call and `probePortsFree` was permanently `false`. With `portsFree`
always false, `decideArbitration` could never return `spawn` - on a clean machine
it returned `conflict` ("ports occupied by an unhealthy process; not starting
backend") and the app never started its own surreal + ax serve. The packaged app
then surfaced that conflict via a modal during bootstrap and crashed.
Use Node's `net.createServer().listen({ exclusive: true })` instead (runtime that
actually hosts this code), resolving `false` on bind error. The `attach` path was
unaffected (HTTP probes), which is why pre-starting a CLI daemon was a working
workaround.
Verified: arbitration suite green; node:net detects free vs occupied ports under
the Node runtime (a held :8521 reports EADDRINUSE / occupied).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying ax with
|
| Latest commit: |
7bfe1ba
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ca86350c.ax-62d.pages.dev |
| Branch Preview URL: | https://fix-614-bug-studio-desktop-b.ax-62d.pages.dev |
This was referenced Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #614.
Bug
AxDaemonArbitration.portFreeprobed port availability withBun.listen, but the Electron main process runs under Node, not Bun —Bunisundefinedthere. Every bind probe threw →probePortsFreewas permanentlyfalse→decideArbitrationcould never returnspawn:…with
lsofshowing nothing on 8521/1738. So on a clean machine the app never started its own backend; the packaged app surfaced the conflict via a bootstrap modal and crashed.Fix
Use Node's
net.createServer().listen({ host: "127.0.0.1", port, exclusive: true })— the runtime that actually hosts this code — resolvingfalseon bind error. Total, never fails. Theattachpath (HTTP probes) was unaffected, which is why pre-starting a CLI daemon worked around it.Verify
tscclean.node:netcorrectly detects free vs occupied ports under the Node runtime (a held:8521reportsEADDRINUSE).Note: this is one of two issues behind the desktop crash. The other — the installed app failing with
Cannot find module 'electron-updater'— is a stale build; current source already bundles electron-updater (require('electron-updater')count = 0 in a freshmain.cjs). A rebuilt app picks up both.🤖 Generated with Claude Code