eclipse-vertx/vert.x · info · IllegalStateException
Result is already complete
Error message
Result is already complete
What it means
SC_GATEWAY_TIMEOUT is an HttpResponseExpectation constant asserting an HTTP 504 status. When used as a client expectation it fails any response whose status is not exactly 504, reporting '504 Gateway Timeout'.
Source
Thrown at vertx-core/src/main/java/io/vertx/core/Promise.java:76
default void complete(T result, Throwable failure) {
if (failure == null) {
succeed(result);
} else {
fail(failure);
}
}
/**
* Set the result. Any handler will be called, if there is one, and the promise will be marked as completed.
* <p/>
* Any handler set on the associated promise will be called.
*
* @param result the result
* @throws IllegalStateException when the promise is already completed
*/
default void complete(T result) {
if (!tryComplete(result)) {
throw new IllegalStateException("Result is already complete");
}
}
/**
* Calls {@code complete(null)}
*
* @throws IllegalStateException when the promise is already completed
*/
default void complete() {
if (!tryComplete(null)) {
throw new IllegalStateException("Promise already completed");
}
}
default void succeed(T result) {
if (!tryComplete(result)) {
throw new IllegalStateException("Promise already completed");
}View on GitHub (pinned to fb308bd8c3)
Solutions
- Increase upstream processing performance or gateway/proxy timeout settings so requests complete in time.
- Add client-side timeouts and retries with backoff for idempotent requests.
- If 504 is the intended contract (timeout tests), keep SC_GATEWAY_TIMEOUT and ensure the proxy timeout is shorter than the client timeout.
Example fix
// before request.expect(HttpResponseExpectation.SC_GATEWAY_TIMEOUT).send(); // after request.expect(HttpResponseExpectation.status(200)).send();
Defensive patterns
Strategy: retry
Validate before calling
long started = System.nanoTime();
if (response.statusCode() == 504) { /* upstream timeout: back off and retry idempotent ops */ } Prevention
- Size gateway timeouts above realistic upstream p99 latency.
- Set explicit client timeouts shorter than the gateway's so the client fails first.
- Load-test slow endpoints before production.
When it happens
Trigger: Applying request.expect(HttpResponseExpectation.SC_GATEWAY_TIMEOUT) to a response with a different status; matching responses where an upstream gateway/proxy timed out.
Common situations: Upstream service latency exceeded the proxy timeout in production; load tests deliberately provoking gateway timeouts; asserting timeout semantics in proxy integration tests.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- maxExecuteTime must be > 0
- size must be > 0
- Promise already completed
- eventLoopPoolSize must be > 0
- 408 Request Timeout
AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06).
Data as JSON: /api/errors/db2123e41d050cfb.
Report an issue: GitHub.