RFC 2 / Draft

Sibling errors should not be added after propagation

Opened on
Updated on

At a glance

Project
GraphQL Spec
Identifier
#1184
Stage
RFC 2 / Draft
Champion
@benjie
Updated
2026-09-17
Latest activity
2 commits pushed on
Source

Pull request description

This PR is built on top of:

  • #1183

GraphQL.js output is not (currently) stable after an operation terminates: more errors may be added to the result after the promise has resolved!

<details> <summary>Reproduction with `graphql` module `test.mts`</summary>
import type { ExecutionResult } from "graphql";
import {
  graphql,
  GraphQLInt,
  GraphQLNonNull,
  GraphQLObjectType,
  GraphQLSchema,
} from "graphql";

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

const Test = new GraphQLObjectType({
  name: "Test",
  fields: {
    a: {
      type: GraphQLInt,
      async resolve() {
        await sleep(0);
        throw new Error(`a`);
      },
    },
    b: {
      type: new GraphQLNonNull(GraphQLInt),
      async resolve() {
        await sleep(10);
        throw new Error(`b`);
      },
    },
    c: {
      type: GraphQLInt,
      async resolve() {
        await sleep(20);
        throw new Error(`c`);
      },
    },
  },
});

const Query = new GraphQLObjectType({
  name: "Query",
  fields: {
    test: {
      type: Test,
      resolve() {
        return {};
      },
    },
  },
});
const schema = new GraphQLSchema({
  query: Query,
});

const result = await graphql({
  schema,
  source: `{ test { a b c } }`,
});

console.log("Result:");
console.log();
console.log(JSON.stringify(result, null, 2));
await sleep(100);
console.log();
console.log("Exact same object 100ms later:");
console.log();
console.log(JSON.stringify(result, null, 2));
</details>
$ node test.mts 
Result:

{
  "errors": [
    { "message": "a", "path": ["test", "a"] },
    { "message": "b", "path": ["test", "b"] }
  ],
  "data": { "test": null }
}

Exact same object 100ms later:

{
  "errors": [
    { "message": "a", "path": ["test", "a"] },
    { "message": "b", "path": ["test", "b"] },
    { "message": "c", "path": ["test", "c"] }
  ],
  "data": { "test": null }
}

(I've formatted this output for brevity)

The reason for this: though we note in the spec that you may cancel sibling execution positions, we don't do that in GraphQL.js; and furthermore, we even process errors from the result and add them to the errors list!

This is particularly problematic for client-side "throw on error". Given this schema:

type Query {
  test: Test
}
type Test {
  a: Int  # Throws immediately
  b: Int! # Throws after 10ms
  c: Int  # Throws after 20ms
}

And the same spec-valid result as above:

{
  "errors": [
    { "message": "a", "path": ["test", "a"] },
    { "message": "b", "path": ["test", "b"] },
    { "message": "c", "path": ["test", "c"] }
  ],
  "data": { "test": null }
}

Technically the Test.b field is the field that caused data.test to be null - it's non-nullable, so it triggered error propagation - but without looking at the schema we can't determine this.

Solution: recommend that servers don't keep adding to errors after error propagation has occurred. This would mean:

  1. GraphQL.js won't keep adding to errors after the operation has "completed"
  2. We can throw the last error received that relates to the associated field, and trust that for an implementation following the recommendations it's going to be the one either from the field itself or from the field that triggered error propagation to this level.

Timeline

September 2026

  • 2 commits pushed on
  • Discussed in GraphQL WG

    The September Secondary Working Group for the GraphQL specification met to review several agenda items and discuss updates to the specification. The group reviewed and approved three items for merge: one-off inhabitability, allow empty selection sets, and clarification of response position definitions. They also discussed error propagation rules, with Benjie proposing that sibling errors should not be added after propagation, which the group agreed to merge with minor editorial changes. The team reviewed the HTTP specification updates, including notes about new status code 294 for partial success, and decided to proceed with the spec cuts planned for the following Thursday. Rob presented updates on the defer stream specification, focusing on improvements to the visited fragments algorithm to prevent potential complexity explosions, which Benjie agreed to review for potential security issues.

    Zoom summary · GraphQL WG · 2026-09-17
    Next Steps

    Benjie: Clean up the wording in the note for pull request 1184 (errors after propagation) after the call.

    Zoom summary · GraphQL WG · 2026-09-17

    The team discussed a constraint regarding error handling in GraphQL, specifically that only one error should be added to the error list per response position. Leebyron and Benjie clarified that this restriction helps prevent issues with client behavior that might incorrectly display or handle multiple errors. The group agreed to maintain this constraint as it provides simplicity and avoids potential complications with error aggregation. They also reviewed a related change (pull request 1184) that addresses how errors should not be added to the list after an error has propagated, though this is stated as a "should" rather than a mandatory requirement.

    Zoom summary · GraphQL WG · 2026-09-17
    GraphQL Error Propagation Discussion

    Leebyron and Benjie discussed the handling of errors in GraphQL when multiple fields execute in parallel. Benjie explained that according to the GraphQL specification, when an error occurs in a non-null field, it should propagate and other sibling fields should stop executing. They agreed that the server, not the client, should determine which error to propagate, and that clients should not rely on specific error handling mechanisms. Leebyron suggested clarifying the language around canceled positions and error propagation, and they decided to merge notes for better clarity without repeating information.

    Zoom summary · GraphQL WG · 2026-09-17

    Benjie and Leebyron discussed specifications around error handling in GraphQL, particularly regarding how multiple errors should be handled when canceling operations. They agreed that the current "should" language in the specification provides appropriate guidance to clients while allowing flexibility for different implementation approaches. The team also reviewed changes to operation execution definitions that were previously merged, with Mark expressing interest in incorporating the mermaid diagrams into the documentation website. The conversation ended with a discussion about potentially freezing the current spec or making further changes before a November cut.

    Zoom summary · GraphQL WG · 2026-09-17
  • @benjie committed "Address Lee's feedback" on
  • Marked as Ready for Next Stage on by benjie

July 2026

  • Advanced to RFC 2 on by leebyron
  • Discussed in GraphQL WG

    The GraphQL Working Group held their July meeting to review multiple specification proposals and updates. The group discussed best practices for writing robust applications, with Martin presenting a new documentation page on handling schema changes that received approval for immediate merging. James updated the team on one-of-inhabitability specifications, which moved to Stage 2 pending final review, while Pascal provided an overview of OTel semantic conventions requiring TSC approval before merging. Benjie presented several proposals including sibling errors, empty selection sets, empty object types, interfaces with no fields, and unions with no members, with the group supporting these changes and moving them to RFC 2 status. The team also reviewed the GraphQL over HTTP specification, which was nearly ready for release with only minor editorial changes remaining. The conversation ended with plans to complete spec freeze preparations for the upcoming August meeting and September/October specification cut.

    Zoom summary · GraphQL WG · 2026-07-02

    The GraphQL Working Group meeting began with introductions from attendees including Lee, Benjie from Graphile, James from Airbnb, Martin from Apollo, Pascal and Michael from ChilliCream, Matt from Meta, and Mark from Yelp. Lee announced that the group would conduct a spec freeze before next month's meeting, aiming to complete it by August for the September/October cut. The meeting then moved to reviewing the agenda, which included discussing best practices for writing robust applications, including topics about sibling errors, empty selection sets, interfaces, and schema validation requirements.

    Zoom summary · GraphQL WG · 2026-07-02

    Benjie presented updates on two GraphQL specification changes. The first addresses an issue in GraphQL JS where errors arrays might grow after receiving a response, which has been resolved in version 17 by changing the behavior from a "must" to a "should" requirement. The second proposal allows empty selection sets, which will help with client-derived fields and schema design, though it requires implementation in GraphQL JS. Leebyron marked both proposals as RFC 2 pending implementation, and the group discussed that while this makes the grammar more general, it should not break existing documents but might not be compatible with older servers.

    Zoom summary · GraphQL WG · 2026-07-02

July 2025

  • Discussed in GraphQL WG

    GraphQL Error Propagation Changes

    Benjie discussed an issue with error propagation in GraphQL where errors could be added to the errors array after the response was sent, potentially leading to unexpected behavior. He proposed a change to the spec to prevent further errors from being added once an error has propagated, ensuring that only the error from the non-nullable field that caused the null value is thrown. Leebyron raised concerns about the complexity of enforcing this rule in parallel processing scenarios and suggested alternative approaches like including both the origin and settlement positions of errors. They also discussed the original motivation for error propagation, which was to address product engineering needs for safe data access, and considered how to better support these use cases in GraphQL.

    Zoom summary · GraphQL WG · 2025-07-17
  • Top comment edited on by benjie
  • Pull request created on by benjie
  • @benjie committed "Sibling errors should not be added after propagation" on
  • Advanced to RFC 0 on by benjie