Skip to content

Commit d83b3b4

Browse files
Force IPv4-first DNS resolution for outbound requests
The GitHub update check was timing out (8s) on a self-hosted box whose resolver returns no working IPv6 for api.github.com (curl -4 succeeds, curl -6 can't even resolve). Node's fetch attempted IPv6 and stalled. setDefaultResultOrder('ipv4first') at startup mirrors 'curl -4' and fixes the check (and any other outbound calls).
1 parent a566177 commit d83b3b4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎apps/api/src/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Side-effect import: must come first so .env is loaded before anything reads process.env.
22
import './config/dotenv.js';
3+
import { setDefaultResultOrder } from 'node:dns';
34
import { mkdir } from 'node:fs/promises';
45
import { loadEnv } from './env.js';
56
import { createContext } from './context.js';
@@ -8,6 +9,11 @@ import { startRemoteWorker } from './worker/remote-worker.js';
89
import { startMaintenance } from './services/maintenance.js';
910
import { prisma } from './db.js';
1011

12+
// Prefer IPv4 when resolving outbound hosts. Some self-hosted boxes advertise IPv6 but have
13+
// no working IPv6 route (or no AAAA records), which makes Node's fetch hang until it times out
14+
// — e.g. the GitHub update check. Resolving IPv4-first mirrors `curl -4` and avoids the stall.
15+
setDefaultResultOrder('ipv4first');
16+
1117
async function main(): Promise<void> {
1218
const env = loadEnv();
1319
const ctx = createContext(env);

0 commit comments

Comments
 (0)