v6: fix transport error metadata, subscription teardown, and the spec accept header - #4429
Merged
Merged
Conversation
|
| Name | Type |
|---|---|
| @graphiql/toolkit | Minor |
| @graphiql/react | Minor |
| graphiql | Minor |
| @graphiql/plugin-history | Major |
| @graphiql/plugin-code-exporter | Major |
| @graphiql/plugin-collections | Major |
| @graphiql/plugin-doc-explorer | Major |
| @graphiql/plugin-query-builder | Major |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
trevor-scheer
force-pushed
the
trevor/transport-correctness
branch
from
August 11, 2026 01:11
0b32914 to
aded491
Compare
trevor-scheer
marked this pull request as ready for review
August 26, 2026 13:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A handful of independent correctness fixes to the v6 transport path, mostly around error handling and cancellation.
Non-JSON response bodies. The transports called
response.json()unconditionally, so a body that isn't JSON (an HTML error page from a proxy, a plain-text 401) madesend()reject and lose exactly the wire metadata the transport exists to provide.readResponseBodynow reads the body as text and folds a parse failure into a synthetic{ errors: [{ message: <raw text> }] }body, keeping the real status, headers, timing, and size. A plain-textBad Gatewaynow renders asBad Gateway, which also let the Cypress test stop pinning Electron's JSON-parser wording.oksemantics.TransportResponse.okonly consulted the GraphQL body, so a 401 whose body parsed as JSON with noerrorswasok: true. It's nowresponse.ok && !hasErrorsfor HTTP responses. Subscription events have no HTTP envelope, so they stay body-only.Subscription teardown. Stopping a subscription didn't actually stop it. The store's unsubscriber called
iter[Symbol.asyncIterator]().return?.(), butTransportHookRegistry.wrap()mints a brand-new iterator on every[Symbol.asyncIterator]()call, so Stop disposed a throwaway while the one driving thefor awaitloop kept delivering events forever. The store now captures the iterator once and disposes that same iterator. The legacy fetcher's iterable path had the identical pattern and gets the identical fix. New tests inexecution.spec.tsassert delivery halts afterstop(), both against a raw transport and through the realwrap().Aborting queries/mutations. They had no cancellation at all.
TransportRequestgainssignal, threaded down tofetch, andstop()now aborts the in-flight request.stop()also bumpsqueryIdso a transport that ignores the signal still can't paint a late response, andrun()'scatchdistinguishes a user-initiated abort (silent) from a genuine failure (surfaced). For streams the controller stays armed as an HTTP-level backstop; primary teardown is still iterator disposal.onErrorplugin hook. Plugins could observe requests and responses but not failures.transport.onErrorfires whensend()rejects outright (a network error, a throwingonBeforeSendhook), receiving the request as transformed by whichever hooks had run. Observer callbacks are now isolated: one that throws is logged instead of breaking the stream or masking the original error.wrap()also handles disposal races:return()during an awaitedonBeforeSendprevents the underlyingsend()from firing, and late values/errors after disposal are dropped.Spec
acceptheader. With incremental delivery on (the default), the multipart transport sentaccept: application/json, multipart/mixedwith no mention ofapplication/graphql-response+json, silently asking spec-compliant servers for legacy response semantics. It now sendsmultipart/mixed, application/graphql-response+json;q=0.9, application/json;q=0.8; without explicit q-values every type ties at q=1 and the server's tie-break can route an incremental response away from multipart.Smaller items.
TransportRequestandSubscriptionRequestgainextensions(in the URL forGET, in the body forPOST/QUERY) for things like automatic persisted queries; the two near-identical parse passes increateTransportcollapse into oneclassifySelectedOperation; the never-populatedResolverTracetype is removed fromTransportResponse.timing.