toeverything/AFFiNE · error · GraphQLError
Empty GraphQL error body
Error message
Empty GraphQL error body
What it means
In gqlFetch, when the response has HTTP status >= 400 (or errors) but the JSON body contains no `errors` array, there is nothing meaningful to surface, so an Error('Empty GraphQL error body') is thrown to avoid swallowing the failure.
Source
Thrown at packages/common/graphql/src/fetcher.ts:225
const ret = fetcher(
endpoint,
merge(options.context, {
method: 'POST',
headers,
body: isFormData ? body : JSON.stringify(body),
timeout: options.timeout,
signal: options.signal,
})
).then(async res => {
if (res.headers.get('content-type')?.startsWith('application/json')) {
const result = (await res.json()) as ExecutionResult;
if (res.status >= 400 || result.errors) {
if (result.errors && result.errors.length > 0) {
// throw the first error is enough
const firstError = result.errors[0];
throw new GraphQLError(firstError.message, firstError);
} else {
throw new GraphQLError('Empty GraphQL error body');
}
} else if (result.data) {
// we have to cast here because the type of result.data is a union type
return result.data as any;
}
}
throw new GraphQLError(
'GraphQL query responds unexpected result, query ' + options.query.op
);
});
return ret;
};
return gqlFetch;
};
View on GitHub (pinned to b4c8548c09)
Solutions
- Check network connectivity to the GraphQL endpoint; the error response body was empty.
- Retry the request; transient proxy or server failures can produce empty error bodies.
- Inspect server and proxy logs for the corresponding failed request.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at packages/common/graphql/src/fetcher.ts:225 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/dfbffb14f64b0eea.
Report an issue: GitHub.