Skip to content

Websocket errors are not handled #1100

@Sam-Kruglov

Description

@Sam-Kruglov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions