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: OPTIONS /some/route> body not consumed. #52

Open
digitalkaoz opened this issue Sep 2, 2021 · 3 comments
Open

<Request: OPTIONS /some/route> body not consumed. #52

digitalkaoz opened this issue Sep 2, 2021 · 3 comments

Comments

@digitalkaoz
Copy link

digitalkaoz commented Sep 2, 2021

Hey,

im bending my mind around a weird problem. it only happens occasionally and i cant find the root cause:

app = Sanic(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})

@app.route('/some/route', methods=['GET'])
async def some_route_handler(request: Request) -> HTTPResponse:
    return empty()

when accessing this from a client-side app using axios:

    const response = await axios.get(`some/route`, {
      params: { ...filters } // query params
    });

i sometimes get this error:

{
    "timestamp": "2021-09-02T13:04:39.351303Z",
    "level": "ERROR",
    "message": "<Request: OPTIONS /some/route> body not consumed.",
    "type": "log",
    "logger": "sanic.error",
    "worker": 9,
    "filename": "http.py",
    "lineno": 154,
    "req_id": "28844799-4fe1-4ba1-a5c6-b0933142d709"
}

i literally have no idea whats wrong.

automatic_options=True should be enabled by default afaik.
There is also JWT included but i guess thats not the problem. Any ideas?

Im definitely not sending a Request Body during the preflight request. Everything seems to work, but this problem is spamming my logging system.

@ZSSVE
Copy link

ZSSVE commented May 12, 2022

I saw a similar issue. With automatic_options=True, it looks like that sanic-cors would directly return an empty response around here, while since Sanic 21.3.0 (this commit), setting response without reading the body would trigger an error logging.

I am unclear if our Options requests have body.

@fkromer
Copy link

fkromer commented Jan 30, 2023

With sanic==21.12.1 and Sanic-Cors==2.0.1 this issue still exists. I've not come further here unfortunately yet.

@fkromer
Copy link

fkromer commented Jan 30, 2023

During debugging seems like you can workaround this issue by setting sanic_workers=1. After re-configuring I had the issue not again yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants