pretenderjs / pretender

A mock server library with a nice routing DSL
MIT License
1.26k stars 157 forks source link

Interference between Pretender and React Server Components #360

Open thearnica opened 1 year ago

thearnica commented 1 year ago

Just want to report an issue I found during Next13 adoption - it short navigation between pages is not working.

The problem appears as TypeError: Cannot read properties of undefined (reading 'getReader') at react-server-dom-webpack-client.development.js

Root cause is at startReadingFromStream(response, r.body); with r being Response defined by pretender and .body being not defined.

In short - the underlaying polyfill does not support .body and likely will never support it - https://github.com/github/fetch/issues/1109

This basically means that the problem cannot be resolved in the downstream and might need correction at the pretender level. Why do you need FakeFetch in any case?

bobziroll commented 1 year ago

I'm experiencing a similar problem in React Router ≥v6.4.5. They changed their code to check the response for a body property that's not undefined. Previously, they only checked if the response was an instance of Response which passed, but pretender is returning a response with no body at all, and it's short-circuiting the navigation.