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

[BUG] currently does not support client body read timeout #1054

Closed
chenyukang opened this issue Apr 21, 2023 · 3 comments · Fixed by #1060
Closed

[BUG] currently does not support client body read timeout #1054

chenyukang opened this issue Apr 21, 2023 · 3 comments · Fixed by #1060
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chenyukang
Copy link

From the code:

let server = axum::Server::builder(incoming).serve(app.into_make_service());

Seems godwoken also has a similar issue with ckb, nervosnetwork/ckb#3880

I didn't verify it on godwoken, but from the code the rpc does not has a limit for a request, you can verify it with curl:

curl --location 'http://127.0.0.1:3000/rpc' \
-H 'content-length: 100' \
--header 'Content-Type: application/json' \
--data-raw '   {
        "id": 42,
        "jsonrpc": "2.0",
        "method": "@ping",
        "params": [
        ]
   }'

An possible fix is to add a timeout middleware: https://github.com/chenyukang/jsonrpc-utils/blob/810f6a36eec3ce5be8673c11311bf1dcc506c3f9/examples/server-timeout.rs#L39

@chenyukang chenyukang added the bug Something isn't working label Apr 21, 2023
@blckngm
Copy link
Contributor

blckngm commented Apr 21, 2023

Godwoken rpc is usually proxied by web3 / nginx etc., not exposed directly.

But adding a client body size limit / timeout is pretty easy, so I will add it just in case.

@blckngm blckngm self-assigned this Apr 21, 2023
@blckngm blckngm added enhancement New feature or request and removed bug Something isn't working labels Apr 21, 2023
@Flouse Flouse added the good first issue Good for newcomers label Apr 21, 2023
@blckngm
Copy link
Contributor

blckngm commented Apr 25, 2023

@chenyukang Just use TimeoutLayer from tower-http, no need for ServiceBuilder and HandleErrorLayer.

@chenyukang
Copy link
Author

@chenyukang Just use TimeoutLayer from tower-http, no need for ServiceBuilder and HandleErrorLayer.

Got it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants