@Override
    public void onError(QueryException error) {
        assert error != null;
        done.compareAndSet(null, error);
    }
@Test
    public void when_doneWithErrorWhileWaiting_then_throw_sync() throws Exception {
        initProducer(false);
        Future<?> future = spawn(() -> {
            assertThatThrownBy(() -> iterator.hasNext(1, DAYS))
                    .hasMessageContaining("mock error");
        });
        sleepMillis(50); // sleep so that the thread starts blocking in `hasNext`
        producer.onError(QueryException.error("mock error"));
        future.get();
    }