GraphQL API fetch errors linked to backend update rollback

22 replies
Last updated: May 17, 2024
Hey, I'm getting the following error when trying to fetch data from the GraphQL API. It started erroring 2 days ago. Could this be related to the infrastructure update (https://www.sanity-status.com/ )? If so, when can we expect it to start working again?

 TypeError: terminated
     at Fetch.onAborted (node:internal/deps/undici/undici:10916:53)
     at Fetch.emit (node:events:518:28)
     at Fetch.emit (node:domain:488:12)
     at Fetch.terminate (node:internal/deps/undici/undici:10102:14)
     at Object.onError (node:internal/deps/undici/undici:11034:38)
     at Request.onError (/Users/<redacted>/node_modules/next/dist/compiled/undici/index.js:1:103010)
     at errorRequest (/Users/<redacted>/node_modules/next/dist/compiled/undici/index.js:1:83029)
     at TLSSocket.onSocketClose (/Users/<redacted>/node_modules/next/dist/compiled/undici/index.js:1:70729)
     at TLSSocket.emit (node:events:530:35)
     at TLSSocket.emit (node:domain:488:12) {
   [cause]: SocketError: other side closed
       at TLSSocket.onSocketEnd (/Users/<redacted>/node_modules/next/dist/compiled/undici/index.js:1:70251)
       at TLSSocket.emit (node:events:530:35)
       at TLSSocket.emit (node:domain:488:12)
       at endReadableNT (node:internal/streams/readable:1696:12)
       at processTicksAndRejections (node:internal/process/task_queues:82:21) {
     code: 'UND_ERR_SOCKET',
     socket: {
       localAddress: '192.168.88.182',
       localPort: 64602,
       remoteAddress: '34.111.181.219',
       remotePort: 443,
       remoteFamily: 'IPv4',
       timeout: undefined,
       bytesWritten: 3422,
       bytesRead: 73206
     }
   }
 }
AI Update

I can see you're experiencing a network-level error (UND_ERR_SOCKET with "other side closed") when trying to fetch from Sanity's GraphQL API. This type of error indicates the connection is being terminated unexpectedly, which can have several causes.

Understanding the error:

The TypeError: terminated with the underlying SocketError: other side closed from undici (Node's HTTP client) means your request started but the connection was closed before completing. This is a network/connection issue rather than a GraphQL query problem.

Possible causes:

  1. Network/Infrastructure issues: Could be related to Sanity's infrastructure, your hosting provider, or network path between them
  2. Rate limiting: If you're making many requests (especially during development with hot reload), you might be hitting rate limits
  3. Timeout issues: Large GraphQL queries or slow responses timing out
  4. DNS/routing problems: Issues resolving or reaching Sanity's API servers
  5. Local network issues: Firewall, proxy, or ISP interference

Immediate troubleshooting steps:

  1. Check Sanity's status: Visit sanity-status.com to see if there are any ongoing incidents. If there's an active incident, you'll need to wait for Sanity's team to resolve it.

  2. Verify your endpoint: Ensure you're using the correct GraphQL API endpoint format. The GraphQL API should be deployed using sanity graphql deploy and accessed at your project's apicdn domain.

  3. Test with GROQ as a workaround: While troubleshooting, you can use GROQ queries via the HTTP API as an alternative to verify if the issue is specific to GraphQL or affects all API access.

  4. Network diagnostics:

    • Try from a different network (mobile hotspot, different WiFi)
    • Flush your DNS cache
    • Check if you can reach the endpoint with curl to test basic connectivity
  5. Code-level fixes:

    • Add retry logic with exponential backoff
    • Increase timeout values in your fetch configuration
    • If using Next.js, check if you're hitting this during build vs runtime
  6. Check for rate limiting: If you're fetching the GraphQL schema on every build or hot reload, you might be hitting rate limits. Consider caching the schema or reducing fetch frequency during development.

If the issue persists:

Since this started 2 days ago and involves connection termination, it could be infrastructure-related. I'd recommend:

  • Contact Sanity support with your project ID, dataset name, and this error trace
  • Include details about when it started, how frequently it occurs, and whether it affects all environments or just specific ones
  • Ask support if there were any infrastructure changes around the time the issue started

The error you're seeing is at the network/transport layer rather than the GraphQL application layer, which suggests either infrastructure issues or network connectivity problems between your application and Sanity's API servers. The status page will show if there's a known incident, but if everything appears operational there and you're still experiencing issues, support can investigate your specific project.

I have the same issue!
Is this happening any time you fetch data or only on certain occasions?
It definitely happens everytime when fetching the introspection schema, didn’t really check other queries as I can’t run the app because of this error
Weird thing is that it doesn’t happen in the playground
It started on Monday, but then a restart of the app used to help, since today it happens every time
It started failing on production as well, it has been deployed a week ago, so it can’t be a change that I made that broke it. The errors begun appearing in Sentry yesterday
user D
what are you seeing for your case?
If either of you
user H
or
user D
are around and available, can you see if you are still able to reproduce this issue?
user Y
The issue is gone, thank you!
user Y
Actually it just reappeared, it happened once and when I re-run the app it was gone. I'm debugging re-renders in my app, so I've been refreshing it a lot, could this be somehow related to rate limiting? I might have sent a lot of requests since I'm using
webpack-val-loader
to prefetch some data (happens on every build cycle)
Thanks for confirming,
user H
- sorry to hear the issue came back for you. We’ll take this back to the backend team and will keep you posted on any updates.
user Y
I saw the exact same message - but it’s working now
user H
- would you mind sharing your project ID and a failing query to the GraphQL API in a DM? This would help the team run a more specific test to see why you might still be seeing errors.
user Y
I’ve just got the error again
Yeah, it's breaking the pipelines again
user D
sorry to hear the issue returned for you - could you also share your project ID and the failing query in a DM?
user H
user D
we've rolled back a backend update that's tied to the issue, which means you should no longer see the errors now. Please let me know if this doesn't match your experience. Sorry for the impact this had on your deployments.
user M
Thanks, the builds seem to be passing now, will let you know if it happenes again
We are back in my timezone moreso now as a heads up (thanks for jumping in Peter). Wasn’t ignoring your messages earlier
user D
/
user H
. Glad to ehar things are working!
user H
when you can will you please note your ProjectID here (or DM it to me if you feel more comfortable)? Thank you.
user Y
Me and
user D
are actually working on the same project, so you can use the projectId he sent to
user M
Ah that explains - thanks for confirming
user H
🙂

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?