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

Add timeouthandler #310

Merged
merged 3 commits into from
Oct 26, 2020
Merged

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Oct 23, 2020

Wraps around Vert.x TimeoutHandler implementation to write a 500 response if a request is not completed by another handler within 15 seconds

Fixes #288

Easy ways to test: modify the 15_000 constant in the patch to a shorter period, like 500, and then do some operation like generating a report. Or, build a minimal image and try to request a web-client asset.

Wraps around Vert.x TimeoutHandler implementation to write a 500 response if a request is not completed by another handler within 15 seconds

Fixes cryostatio#288
@andrewazores andrewazores requested a review from vic-ma October 23, 2020 18:47
Copy link
Contributor

@vic-ma vic-ma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some handlers, like the handlers to create a recording or view recordings present in a target, don't timeout even with a 1ms timeout. Is that okay/expected?

Also, needs a spotless format.

@andrewazores
Copy link
Member Author

Some handlers, like the handlers to create a recording or view recordings present in a target, don't timeout even with a 1ms timeout. Is that okay/expected?

Hmm. I'm not sure why that would be - I've just wrapped around the Vertx standard timeout handler implementation and added it to the handler chain. Maybe whatever asynchronous monitor is watching for responses to be written to the context doesn't have the timing resolution to be so strict as to reject with timeouts as short as 1ms. Or perhaps we're blocking the event loop on those handlers and so the monitor doesn't actually get processed until after our handler executes - in which case, we need to change the isAsync return value on some handlers.

https://stackoverflow.com/questions/34483476/set-timeout-globally-for-all-operations-in-vert-x-router

The backing implementation is here but it doesn't provide much insight:

https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/TimeoutHandlerImpl.java

Here's a piece of doc which references this setTimer:

https://vertx.io/docs/vertx-core/java/#_executing_periodic_and_delayed_actions

Anyway, the main use case here is to ensure that clients don't get left hanging if:

  1. they try to load the web-client of a minimal build (I've done this to myself several times and it always takes me far too long to realize)
  2. some wild exception occurs and a target connection or jfr-datasource/Grafana connection hangs/dies and we don't catch/handle the exception internally
  3. we write some buggy handler or AuthManager or something that simply doesn't write a response in certain circumstances

All of these are cases where a long timeout of 5+ seconds should be easily caught by whatever async piece is monitoring us under Vertx's hood.

@andrewazores andrewazores merged commit 6eeea40 into cryostatio:main Oct 26, 2020
@andrewazores andrewazores deleted the http-response-timeout branch October 26, 2020 15:31
andrewazores added a commit to andrewazores/cryostat that referenced this pull request Oct 26, 2020
* Add timeouthandler

Wraps around Vert.x TimeoutHandler implementation to write a 500 response if a request is not completed by another handler within 15 seconds

Fixes cryostatio#288

* Add 'L' to long literal

* Apply Spotless formatting
aali309 pushed a commit to aali309/cryostat-legacy that referenced this pull request Jul 22, 2024
…yostatio#310)

Bumps [io.cryostat:cryostat-core](https://github.com/cryostatio/cryostat-core) from 2.29.1 to 2.30.0.
- [Release notes](https://github.com/cryostatio/cryostat-core/releases)
- [Commits](cryostatio/cryostat-core@v2.29.1...v2.30.0)

---
updated-dependencies:
- dependency-name: io.cryostat:cryostat-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

HTTP responses should automatically time out
2 participants