Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intermittent Response.clone: Body has already been consumed error from the dev server #1350

Closed
thescientist13 opened this issue Dec 16, 2024 · 0 comments · Fixed by #1357
Closed
Assignees
Labels
alpha.2 bug Something isn't working CLI v0.31.0
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Dec 16, 2024

Type of Change

Bug

Summary

Have seen this occur in projects sometimes and seeing it more and more in this project adopting Greenwood
thescientist13/HP_Stuff#1

TypeError: Response.clone: Body has already been consumed.
    at webidl.errors.exception (node:internal/deps/undici/undici:3564:14)
    at _Response.clone (node:internal/deps/undici/undici:9081:31)
    at file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@greenwood+cli@0.31.0-alpha.1/node_modules/@greenwood/cli/src/lifecycles/serve.js:70:49
    at async file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@greenwood+cli@0.31.0-alpha.1/node_modules/@greenwood/cli/src/lifecycles/serve.js:55:5

Details

Based on some initial debugging, I think the issue is that we should probably doing a .clone() here
https://github.com/ProjectEvergreen/greenwood/blob/master/packages/cli/src/lifecycles/serve.js#L72

let response = new Response(null, { status });

for (const plugin of resourcePlugins) {
  if (plugin.shouldServe && await plugin.shouldServe(url, request)) {
    const current = await plugin.serve(url, request);
    const merged = mergeResponse(response.clone(), current.clone());

    // added .clone() here
    response = merged.clone();
  }
}

Not sure if there are other instances we should check for? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha.2 bug Something isn't working CLI v0.31.0
Projects
1 participant