stablyai/orca · error · Error
A fetch implementation is required.
Error message
A fetch implementation is required.
What it means
Thrown by createGitHubApiClient when no fetch implementation is available: deps.fetch is not provided AND globalThis.fetch is not a function. The client needs fetch to call the GitHub API, so it refuses to construct without one.
Source
Thrown at config/scripts/run-release-mac-build-workflow.mjs:144
if (run.status === 'completed') {
return run
}
console.log(
`Mac release build workflow is ${run.status}; polling again in ${options.pollSeconds}s`
)
await sleep(options.pollSeconds * 1000)
}
throw new Error(
`Timed out after ${options.timeoutMinutes}m waiting for mac release build workflow ${workflowRunId}.`
)
}
export function createGitHubApiClient(options, deps = {}) {
const fetchImpl = deps.fetch ?? globalThis.fetch
if (typeof fetchImpl !== 'function') {
throw new Error('A fetch implementation is required.')
}
const [owner, repo] = options.repo.split('/')
if (!owner || !repo) {
throw new Error(`GITHUB_REPOSITORY must be in owner/repo form, got "${options.repo}".`)
}
return {
owner,
repo,
async request(method, path, body) {
const response = await fetchImpl(`${options.apiBaseUrl}${path}`, {
body: body == null ? undefined : JSON.stringify(body),
headers: {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${options.token}`,
'Content-Type': 'application/json',
'X-GitHub-Api-Version': DEFAULT_API_VERSIONView on GitHub (pinned to 1136503c6a)
Solutions
- Run on Node 18+ where globalThis.fetch is built in.
- Pass a fetch implementation via deps: createGitHubApiClient(options, { fetch: undici.fetch }) (or node-fetch).
- In tests, inject a mock fetch through the deps parameter.
Example fix
// before
const api = createGitHubApiClient(options)
// after
import { fetch } from 'undici'
const api = createGitHubApiClient(options, { fetch }) Defensive patterns
Strategy: validation
Validate before calling
const fetchImpl = deps.fetch ?? globalThis.fetch
if (typeof fetchImpl !== 'function') {
throw new Error('Provide a fetch impl: createGitHubApiClient(options, { fetch: undici.fetch })')
} Type guard
function isFetch(value) { return typeof value === 'function' } Try / catch
try {
api = createGitHubApiClient(options)
} catch (err) {
if (/fetch implementation is required/.test(err.message)) {
const { fetch } = await import('undici')
api = createGitHubApiClient(options, { fetch })
} else throw err
} Prevention
- Require Node 18+ in package.json engines so global fetch exists.
- Inject a fetch double in tests via the deps.fetch parameter.
- Fail fast at startup with a clear message rather than deep in a request.
When it happens
Trigger: Running on a Node runtime older than 18 (no global fetch), or in a host that undefined globalThis.fetch, while calling createGitHubApiClient without passing deps.fetch.
Common situations: Node 16 EOL runtime, a sandbox that strips fetch, tests that don't inject a fetch double, running the module under an older embedded JS engine.
Related errors
- GitHub request failed ${res.status} ${res.statusText}: ${bod
- GitHub releases response page ${page} for ${repo} was not an
- repo is required
- token is required
- GitHub request failed ${res.status} ${res.statusText}: ${bod
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/6fb039127287e6f2.
Report an issue: GitHub.