rsocket / rsocket-js

JavaScript implementation of RSocket

Home Page:https://github.com/rsocket/rsocket-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When empty result returned for RequestResponse, nothing happened on client side

kevinat opened this issue · comments

commented

We are using Spring RSocket, when server returns an Mono.empty() in RequestResponse, none of the Single subscriber callbacks invoked, so we don't known whether the request is finished.

Is there any possible to trigger the onComplete callback with an undefined argument when the RSocket stream completed while RequestResponse?

commented

#89
Same problem caused by client callback mechanism.

I found the code associated: RSocketMachine.js at line 305
https://github.com/rsocket/rsocket-js/blob/master/packages/rsocket-core/src/RSocketMachine.js#L305

  requestResponse(payload: Payload<D, M>): Single<Payload<D, M>> {
    const leaseError = this._useLeaseOrError(this._requesterLeaseHandler);
    if (leaseError) {
      return Single.error(new Error(leaseError));
    }

    const streamId = this._getNextStreamId(this._receivers);
    return new Single(subscriber => {
      this._receivers.set(streamId, {
        onComplete: () => {},
        onError: error => subscriber.onError(error),
        onNext: data => subscriber.onComplete(data),
      });

May be this is better:

    return new Single(subscriber => {
      this._receivers.set(streamId, {
        onComplete: () => subscriber.onComplete(),
        onError: error => subscriber.onError(error),
        onNext: data => subscriber.onNext(data),
      });

I don't think it's a problem to receive data from onNext. On the contrary, this may be the right "Reactive" way.

commented

#78
Sorry, same issue.