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

Request body buffer not correctly cleared under heavy load #1430

Closed
alexus37 opened this issue Dec 11, 2024 · 2 comments
Closed

Request body buffer not correctly cleared under heavy load #1430

alexus37 opened this issue Dec 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@alexus37
Copy link

alexus37 commented Dec 11, 2024

Component(s)

router

Component version

v0.0.0-20240927172855-3e390cd5cf6c

wgc version

None

controlplane version

None

router version

v0.0.0-20240927172855-3e390cd5cf6c

What happened?

Description

We created a test script written in go that iterates for a list of test queries and uses go routines to make requests to the router which is running on the same machine. For some of the those requests this line raise the following graphQL error:

{"errors":[{"message":"error parsing request body: invalid character '{' after top-level value"}]}

when I look at the httpOperation.body I am seeing two post bodies inside eg.

"{\"query\": \"query {\\n  rateLimit {\\n    limit\\n    remaining\\n    resetAt\\n  }\\n}\"}{\"query\": \"query GetRepositoryMergeQueue {\\n  repository(owner: \\\"<REDACTED>\\\", name: \\\"<REDACTED>\\\") {\\n    mergeQueue {\\n      id\\n    }\\n  }\\n}\"}"

However, when I check what request is being received there is only 1 query in the body. It seems that the ReadBody function here is appending the new query to the buffer where the old query is already in. I am not sure if I need to start the router somehow differently or if I missed something else? When I do the requests sequentially I do not encounter this issue.

Steps to Reproduce

Create a script which uses go routines to target the router. I can pretty consistently reproduce it with 100 queries in total. The router fails on different queries so it seems there is some kind of race condition involved.

Expected Result

Have only the current post body in the buffer

Actual Result

The previous post body is still present in the buffer and the request fails.

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Package Manager: pnpm, npm, yarn, etc
Compiler(if manually compiled): (e.g., "go 14.2")

Router configuration

version: "1"

dev_mode: true
listen_addr: 0.0.0.0:13002
execution_config:
  file:
    watch: true
    path: dev.supergraph.json

modules:
  custom-module-id:
    module-input-var: 2

# See https://cosmo-docs.wundergraph.com/router/proxy-capabilities#forward-http-headers-to-subgraphs
headers:
  all:
    request:
      - op: "propagate"
        named: Authorization

Router execution config

Log output

Additional context

We are only looking at query plans so all the requests are executed with these headers

{
  "X-WG-TRACE": "false",
  "X-WG-Skip-Loader": "true",
  "X-WG-Include-Query-Plan": "true",
}
@alexus37 alexus37 added the bug Something isn't working label Dec 11, 2024
Copy link

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

@Noroth
Copy link
Contributor

Noroth commented Dec 17, 2024

Hi @alexus37 thanks for submitting an issue.

This has been fixed in #1447, which is available in router version 0.152.1.

@Noroth Noroth closed this as completed Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants