zth / rescript-relay-router

MIT License
16 stars 3 forks source link

Fix server fetch function duplicate request bug. #138

Closed chrischen closed 1 year ago

chrischen commented 1 year ago

Observable.subscribe causes the registered Observable function to be run each time it is subscribed. Since the registered function makes a fetch call, it is done a second time here. The error doesn't manifest if the returned data is the same, but if it is different, it will cause a hydration mismatch. The "do" method allows the Observable to run a side-effect on an existing subscription for all events (past and future): https://github.com/facebook/relay/blob/main/packages/relay-runtime/network/RelayObservable.js#L224.

zth commented 1 year ago

Thank you 👍 ! I applied this fix this while fixing another issue. Could you PR adding do to RescriptRelay itself?