How to make a Lagom streaming ServiceCall fail?

I’m having a bit of troubles understanding the default behavior of a streaming ServiceCall:

// Definition
ServiceCall<Source<String, NotUsed>, Done> doSomething();

// Implementation
public ServiceCall<Source<String, NotUsed>, Done> doSomething() {
    return source -> {
        throw new TransportException(TransportErrorCode.InternalServerError, new ExceptionMessage("Internal server error", "..."));
    };
}

The consumer of this server however, never sees the TransportException

@Test
public void testShouldFail() {
    MyService service = server.client(MyService.class);

    Source<String, NotUsed> input = Source.empty();
    CompletableFuture<Done> future = service.doSomething().invoke(input).toCompletableFuture();

    ServiceTest.eventually(FiniteDuration.apply(5, SECONDS), () -> {
        assertThat(future.isCompletedExceptionally()).isTrue();
    });
}

I have the feeling that it has to do with some magic running under the hood, because when I move the TransportException outside of the lambda, the future fails as expected.

Is there anything I’m missing here?

Ok the issue has been found!

The key was to include .concat(Source.maybe()) to the test Source (in this case Source.empty().concat(Source.maybe())).

The second way was to increase the 5 seconds timeout, as it just needed more time and was therefor always failing…