Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 9c0ac81d5f POST /metadata response body consumed before client receives it
https://sonarly.com/issue/4770?type=bug

The useCachedMetadata GraphQL Yoga plugin calls response.json() in its onResponse hook, which consumes the Response body stream on Node.js 24+. On cache-miss requests for ObjectMetadataItems and FindAllCoreViews operations, the client receives an empty response because the body has already been read.

Fix: Replace response.json() with response.clone().json() in the onResponse cache-miss branch. Calling clone() before json() creates a copy of the Response whose body stream is read for the cache-population logic, while the original Response object's body stream remains unconsumed and intact for graphql-yoga to forward to the HTTP client. This is the standard WHATWG Fetch API pattern for reading a response body without side-effecting the original stream.
2026-02-23 01:37:40 +00:00
@@ -90,7 +90,7 @@ export function useCachedMetadata(config: CacheMetadataPluginConfig): Plugin {
const cachedResponse = await config.cacheGetter(cacheKey);
if (!cachedResponse) {
const responseBody = await response.json();
const responseBody = await response.clone().json();
if (responseBody.errors) {
return;