Repository navigation
Conversation
SDK Size
|
|
|
||
| if (!nativeMultipartRequest) { | ||
| return resolvedFallbackAdapter(config); | ||
| return Promise.reject( |
There was a problem hiding this comment.
This used to fall back to the default adapter, now it rejects. I think that’s fine (probably ?) since we can’t fall back without importing axios, but transformRequest also runs between the interceptor and the adapter, so the message probably shouldn’t only blame interceptors. Maybe something like “the request body changed after it was routed to the native uploader”.
|
|
||
| it('rejects when an interceptor replaces the file body after it was routed natively', async () => { | ||
| const client = getTestClient(); | ||
| preserveRequestData(client); |
There was a problem hiding this comment.
If I understand ths properly, every test swaps transformRequest for a noop so nothing covers the real flow where the interceptor sees the body before the transform and the adapter sees it after.
Could we add one test that keeps the default transformRequest and goes through postForm with a FormData ? Like a complete flow override basically
| installNativeMultipartAdapter(client); | ||
|
|
||
| expect(client.axiosInstance.defaults.adapter).toBe(defaultAdapter); | ||
| expect(client.axiosInstance.defaults.adapter).toEqual(['xhr', 'http', 'fetch']); |
There was a problem hiding this comment.
nitpick
I think this is probably not needed, the referential equality should already cover everything.
Since this uses axios internals, it might break in the future (albeit super unlikely, cause half the internet probably relies on this :D )
…1909) https://linear.app/stream/issue/REACT-1225/ensure-stream-chat-js-parses-api-error-correctly-if-multiple-axios Noticed this while I was checking [duplicate message id handling](#1907) in v10. In RN SampleApp, this doesn't work correctly because SampleApp has two copies of axios: - One from `stream-chat` installed by SampleApp - One from the SDK's `stream-chat` copy - When RN calls `installNativeMultipartAdapter,` it replaces SampleApp's axios adapter with the RN SDK's adapter copy and `error instanceof AxiosError` will always return `false`, which meant errors weren't parsed properly - The root cause is that RN shouldn't import from `axios`, fixed here: GetStream/stream-chat-react-native#3853 - Still, this fix makes sense regardless of RN fixed, stream-chat-js is updated to do a more robust `isAxiosError(error)` check, instead of relying on `instanceof`
https://linear.app/stream/issue/REACT-1225/ensure-stream-chat-js-parses-api-error-correctly-if-multiple-axios
Avoid importing
axiosfrom RN SDK. It can cause duplicate copies of Axios.