Closed
Description
Describe the bug
HttpRequestInvokerImpl swallows Exception that prevents sending the error description to client e.g., for timeout error
try {
GraphQLQueryResult result = invoke(invocationInput, request, response).join();
writeResultResponse(invocationInput, result, request, response);
} catch (Exception t) {
writeErrorResponse(t, response);
}
To Reproduce
Steps to reproduce the behavior:
Define a Timeout Instrumentation as follows:
private static class MaxQueryTimeInstrumentation extends SimpleInstrumentation
{
// Time limit in milliseconds
private long maxQueryTime = 5000;
public MaxQueryTimeInstrumentation(long maxQueryTime)
{
this.maxQueryTime = maxQueryTime;
}
private static class TimerInstrumentationState implements InstrumentationState
{
private Instant start = Instant.now();
private boolean test(long maxQueryTime)
{
return ChronoUnit.MILLIS.between(start, Instant.now()) > maxQueryTime;
}
}
@Override
public InstrumentationState createState()
{
return new MaxQueryTimeInstrumentation.TimerInstrumentationState();
}
@Override
public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters)
{
if (((MaxQueryTimeInstrumentation.TimerInstrumentationState) parameters.getInstrumentationState())
.test(maxQueryTime))
throw new GraphQLException("allocated time limit exceeded");
return super.beginFieldFetch(parameters);
}
}
Run a query that times out.
Expected behavior
If request times out then there will be Exception based on timeout and we should be able to let client know that request timed out.