pingdotgg / pingdotgg/t3code

[Bug]: Backend child crashes with setTypeOfService EINVAL and restart-loops on macOS

Open
#9,264 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

Before submitting
  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
Area

apps/desktop

Steps to reproduce
  1. macOS, T3 Code Alpha desktop app, left running with a normal workspace open.
  2. Wait a few minutes without interacting.
  3. A banner appears: ": Failed to connect. Reconnecting..." with
    "Failed to fetch remote environment endpoint
    http://127.0.0.1:3773/.well-known/t3/environment (HttpClientError:
    Transport error)".
  4. The banner clears on its own, then reappears roughly every minute or two.

Confirming it's a crash rather than a network blip:
ps aux | grep "apps/server/dist/bin.mjs"
The backend PID differs from the one that was running at app launch, and
its start time is later than the main app process.

Expected behavior

The backend child stays up for the life of the desktop session. If it does
die, the UI should say the backend crashed rather than reporting a
connection problem.

Actual behavior

The backend child process exits with an uncaught exception and is
respawned. Each crash/respawn cycle surfaces as a "Failed to connect.
Reconnecting..." banner.

The crash is in Node's bundled undici HTTP client calling the new
net.Socket#setTypeOfService API (nodejs/node#61503), which returns EINVAL
on macOS. It throws synchronously from a socket event handler, so nothing
catches it and the process exits with code 1.

This is not T3 Code's own code, but two things here are in scope:

  1. An uncaught exception in the backend child takes down the process and
    leaves the app in a restart loop with no surfaced diagnosis.
  2. The user-facing banner reports a transport/connection failure, which
    sends users looking at networking and saved environments instead of
    at a crashing child process.

Pinning or patching the bundled Node/undici would also avoid it.

Impact

Major degradation or frequent failure

Version or commit

0.0.38

Environment

macOS 27 beta 8

Logs or stack traces
Error: setTypeOfService EINVAL
    at Socket.setTypeOfService (node:net:684:13)
    at writeH1 (node:internal/deps/undici/undici:8022:16)
    at Object.write (node:internal/deps/undici/undici:7758:18)
    at _resume (node:internal/deps/undici/undici:9656:54)
    at resume (node:internal/deps/undici/undici:9589:7)
    at Client.<computed> (node:internal/deps/undici/undici:9370:35)
    at node:internal/deps/undici/undici:9539:26
    at Socket.<anonymous> (node:internal/deps/undici/undici:3342:13)
    at Object.onceWrapper (node:events:630:28)
    at Socket.emit (node:events:509:28) {
  errno: -22,
  code: 'EINVAL',
  syscall: 'setTypeOfService'
}

Node.js v24.18.1

{"message":"backend child process failure output end","level":"ERROR",
 "annotations":{"component":"desktop-backend-child","instanceId":"primary",
 "phase":"END","details":"pid=<pid> code=1"}}

Full log: ~/.t3/userdata/logs/server-child.log
Screenshots, recordings, or supporting files

No response

Workaround

None found. The app recovers on its own after each restart, but the
interruption recurs. Switching Node runtimes isn't possible in a packaged
build.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/desktop by tracing backend child supervision and the reconnect banner, then reproduce the macOS failure and inspect ~/.t3/userdata/logs/server-child.log. Review the apps/server/dist/bin.mjs entry point and the reported Node/undici stack. Done means the child failure is diagnosed and the UI no longer presents a recurring crash as only a transport connection problem.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.