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

Websocket errors are not handled #1100

Open
Sam-Kruglov opened this issue Dec 10, 2024 · 0 comments
Open

Websocket errors are not handled #1100

Sam-Kruglov opened this issue Dec 10, 2024 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@Sam-Kruglov
Copy link

Sam-Kruglov commented Dec 10, 2024

if (response.getData() instanceof Publisher) {
// Subscription
responseFlux = Flux.from((Publisher<ExecutionResult>) response.getData())
.map(ExecutionResult::toSpecification)
.doOnSubscribe((subscription) -> {
Subscription prev = getSessionInfo(session).getSubscriptions().putIfAbsent(id, subscription);
if (prev != null) {
throw new SubscriptionExistsException();
}
});
}

ExecutionResult#getErrors can contain errors but it's never checked. My annotated handlers are not invoked.

I work around this by directly reading the data as Flux:

    @Bean
    fun requestErrorLogger() = WebGraphQlInterceptor { request: WebGraphQlRequest, chain: WebGraphQlInterceptor.Chain
        ->
        chain.next(request).map { response ->
            if (response.getData<Any?>() is Publisher<*>) {
                return@map response.transform {
                    it.data(
                        Flux.from(response.getData<Publisher<ExecutionResult>>()!!)
                            .doOnNext { result ->
                                result.errors.forEach { error ->
                                    log.error(...)
                                }
                            }
                    )
                }
            }
            ...

I assume basically any error that can happen will be missed but if you want a specific case, I had this graphql.TypeMismatchError.

That error came from graphq-java when some resolver failed and the execution result/context contained errors here: https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/SubscriptionExecutionStrategy.java#L165

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants