Search code examples
rxjstimeoutobservablelistenersanity

Operation times out with observable subscription


We have a subscription to an RxJS Observable that's obtained from the Sanity javascript client's listen method.

This works fine except that every now and then we get an error "The operation timed out". I haven't been able to pinpoint exactly when and where this arises but I suspect it happens after a certain timeout without the subscription receiving any message. This does not, however, indicate any issue in our case.

I'm not well versed in observables; is there something basic I'm missing, or has anyone had a similar issue?


Solution

  • Listeners are currently automatically closed after 5 minutes. This might be what you're encountering.

    It's actually a regression that we discovered recently; listeners are supposed to time out only after 30 minutes. We are expecting a fix for it this week. Edit: The fix has now been released.

    It's important for a client to be resilient against any kind of error, though. On the Internet, network timeouts and other glithces are of course very common and must be handled appropriately. eventually the listener will close itself, as this is the intended behaviour.

    (I'm a developer at Sanity.)