sparckles / Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.
https://robyn.tech/
BSD 2-Clause "Simplified" License
4.43k stars 230 forks source link

App fails with "Invalid Header provided" #1008

Closed marchellodev closed 1 week ago

marchellodev commented 1 week ago

Bug Description

I have a very minimal robyn server, and I am sending requests to it via node's fetch.

Locally everything is ok. But when deployed to AWS, sometimes the server would crash with the following logs:

Oct 28 16:58:34 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 28 19:23:56 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 00:54:35 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 03:59:47 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:02:56 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:04:18 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:15:22 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:23:39 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:32:04 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:41:15 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 05:49:47 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 06:06:52 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 06:14:32 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 06:21:47 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 08:59:04 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: ERROR:actix_http.h1.dispatcher:stream error: request parse error: invalid Header provided
Oct 29 09:04:41 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: thread 'actix-rt|system:0|arbiter:4' panicked at src/types/mod.rs:48:18:
Oct 29 09:04:41 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: Unsupported HTTP method
Oct 29 09:04:41 ip-172-31-23-143.eu-north-1.compute.internal python[3595353]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 29 11:20:43 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: thread 'actix-rt|system:0|arbiter:2' panicked at src/types/mod.rs:48:18:
Oct 29 11:20:43 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: Unsupported HTTP method
Oct 29 11:20:43 ip-172-31-23-143.eu-north-1.compute.internal python[3595343]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Seems to be related to https://github.com/actix/actix-web/issues/3102 and https://github.com/seanmonstar/httparse/issues/146

Steps to Reproduce

No response

Your operating system

None

Your Python version (python --version)

3.11

Your Robyn version

latest

Additional Info

No response

VishnuSanal commented 1 week ago

Hi @marchellodev, thanks for reaching out. It's disappointing to discover that you ran into problems. Can you share the code that you used for futher investigation?

marchellodev commented 1 week ago

I bumped node (alpine docker build) from 20 to 23, and now the issue seems to be resolved.

I think it would make sense to investigate this more deeply only if others encounter this problem. So let's just use this issue for tracking that :)

Thanks for such a great library!

sansyrox commented 1 week ago

Closing this now. Will reopen if this is a recurring issue. 😄