hcengineering/platform · critical · NetworkError

Network error ${err}

Error message

Network error ${err}

What it means

NetworkError thrown by fetchSafe when the underlying fetch call itself rejects - the request never got an HTTP response. The original error is logged via ctx.error and embedded in the message. This is a transport-level failure, distinct from HTTP error statuses which produce NotFoundError or DatalakeError.

Source

Thrown at foundations/server/packages/datalake/src/client.ts:532

      while (buffer.length >= chunkSize) {
        yield buffer.subarray(0, chunkSize)
        buffer = buffer.subarray(chunkSize)
      }
    }
    if (buffer.length > 0) {
      yield buffer
    }
  }
}

async function fetchSafe (ctx: MeasureContext, url: string | URL, init?: RequestInit): Promise<Response> {
  let response
  try {
    response = await ctx.with('fetch', {}, () => fetch(url, init), { url: url.toString() }, { span: 'disable' })
  } catch (err: any) {
    ctx.error('network error', { err })
    throw new NetworkError(`Network error ${err}`)
  }

  if (!response.ok) {
    const text = await response.text()
    if (response.status === 404) {
      throw new NotFoundError(text)
    } else {
      throw new DatalakeError(text)
    }
  }

  return response
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Check the wrapped err (in message and ctx.error log) for ECONNREFUSED/ENOTFOUND/CERT codes.
  2. Verify the datalake endpoint URL and port in configuration (this.endpoint).
  3. Confirm the service is running and reachable (curl the endpoint).
  4. Add retry with backoff for transient failures (the service layer's retry() covers get paths).
  5. Fix TLS trust settings (NODE_EXTRA_CA_CERTS) if the error is certificate-related.

Example fix

// before
const client = new DatalakeClient('http://datalake-wrong-host:9000', token)
// after
const client = new DatalakeClient(process.env.DATALAKE_ENDPOINT ?? 'http://datalake:9000', token)
Defensive patterns

Strategy: retry

Validate before calling

// preflight connectivity check
const reachable = await fetch(datalakeEndpoint, { method: 'HEAD' }).then(() => true).catch(() => false)
if (!reachable) throw new Error(`Datalake endpoint unreachable: ${datalakeEndpoint}`)

Type guard

const isNetworkError = (e: unknown): e is NetworkError => e instanceof NetworkError

Try / catch

try {
  await client.statObject(ctx, ws, name)
} catch (err) {
  if (err instanceof NetworkError) {
    await sleep(backoff)
    return client.statObject(ctx, ws, name) // retry transient transport failures
  }
  throw err
}

Prevention

When it happens

Trigger: Any client call routed through fetchSafe (response, getObject, getPartialObject, statObject, deleteObject, uploadFromS3) where fetch rejects: DNS failure, connection refused, TLS handshake error, aborted request, or socket timeout.

Common situations: Wrong endpoint/port in datalake config; datalake service down or unreachable from the container; self-signed cert failing TLS; VPN/firewall blocking; DNS resolution issues.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/b6d7be40fb304f29. Report an issue: GitHub.