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

GraphQL Starter With Starter Web Not Honoring Async Request Timeout #43076

Closed
matthew-js-porter opened this issue Nov 8, 2024 · 4 comments
Closed
Labels
status: duplicate A duplicate of another issue

Comments

@matthew-js-porter
Copy link

When using spring-boot-starter-graphql with spring-boot-starter-web and @EnableAsync I would expect it to honor the spring.mvc.async.request-timeout property. Instead it is throwing a AsyncRequestTimeoutException after 30 seconds.

Steps to Reproduce

  1. Create a project with spring-boot-starter-web and spring-boot-starter-graphql
  2. Add @EnableAsync
  3. Add Property spring.mvc.async.request-timeout=50s
  4. Add QueryMapping method that sleeps.
    @QueryMapping
    @Async
    public CompletableFuture<Book> bookById(@Argument String id) {
        return CompletableFuture.supplyAsync(() -> {
            try {
                LOGGER.info("Starting Sleep");
                TimeUnit.SECONDS.sleep(45);
                return Book.getById(id);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
    }
  1. Send Request and observe error

.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.context.request.async.AsyncRequestTimeoutException]

I observed this behavior using Spring Boot 3.3.5

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 8, 2024
@bclozel
Copy link
Member

bclozel commented Nov 9, 2024

Thanks for raising this and providing a sample.

This has been implemented in #42966 and I'm afraid we cannot backport it to a previous generation.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2024
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 9, 2024
@matthew-js-porter
Copy link
Author

@bclozel the pull request you linked seems to be specific to an SSE request timeout so I would not expect that to address this issue, since the sample being used is not using GraphQL over SSE

@bclozel
Copy link
Member

bclozel commented Nov 9, 2024

Sorry about that. I think this is expected as query mappings don't align one to one with HTTP requests and in general GraphQL is transport agnostic.

If you wish to apply async behavior at the query level you can use one of the return types that involves async behavior. See https://docs.spring.io/spring-graphql/reference/controllers.html#controllers.schema-mapping.return.values

If you would like to discuss this further please create an issue in the spring-graphql project.

@matthew-js-porter
Copy link
Author

@bclozel no worries! I spent some time in the debugger to try and get a better understanding on this and realized it was a async timeout from tomcat. Adding this to the sample fixes the problem.

@Bean
public TomcatConnectorCustomizer tomcatConnectorCustomizer() {
	return connector -> connector.setAsyncTimeout(Duration.ofMinutes(1).toMillis());
}

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants