Thursday, December 21, 2023
HomeiOS Developmentios - TypeError: Can not learn property 'blobId' of undefined - However...

ios – TypeError: Can not learn property ‘blobId’ of undefined – However I am not even utilizing Blobs


Related Packages:

"expo": "~49.0.15",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-fetch-api": "^3.0.0",

Related Code:

const makeRequest = async (payload:IPayload, accessKey:string) => {            
let retryCount = 0;
        let success = false;
        let {physique, methodology, path} = payload;
        var choices = {
            methodology: methodology,
            headers: {
                'Content material-Kind': 'utility/json',
                ...(payload.visitor ? {} : { 'Authorization': 'Bearer ' + accessKey }),
                ...(course of.env.NODE_ENV != 'improvement' ? {} : { 'ngrok-skip-browser-warning': '93'}),
            },
            ... (physique !== null) && { physique: JSON.stringify(physique) }
        };

        do {
            attempt {
                path = payload.logout === true ? props.api.logout:path
                if(payload.stream){
                    choices = {...choices,
                         // @ts-ignore
                        reactNative: { textStreaming: true }}
                }
                const response = await fetch(apiUrl + path, choices);
                if (validHttpCodes.consists of(response.standing)) {
                    setAccessKeyIsValid(true);
                    if (payload.stream) {
                        // It is a STREAM
                        console.log('WE STREAM NOW')
                            let reader:any
                            const cleanup = () => {
                              if (reader) {
                                reader.cancel();
                              }
                            };
                          
                            attempt {
                                reader = response.physique!.getReader();
                              const processStream = async ({performed, worth}: { performed: boolean, worth: Uint8Array }) => {
                                if (performed) {
                                  success = true
                                  cleanup(); // Name the cleanup perform when the stream is completed
                                  if(payload.endStream){
                                    payload.endStream()
                                  }
                                  return;
                                }
                                const textual content = new TextDecoder().decode(worth)
                                console.log('from api'+textual content)
                                payload.callback(textual content);
                                reader!.learn().then(processStream);
                              };
                          
                              reader!.learn().then(processStream);
                              break;
                            } catch (error) {
                              console.error("Error whereas fetching the stream:", error);
                              cleanup(); // Cleanup in case of errors
                            }
                    } else {
                        let jsonResponse = await response.json();
                        if(props.trigger_retry(jsonResponse)==false){
                            if(payload.logout===true){ logout() }

                            jsonResponse = {
                                ...jsonResponse,
                                httpCode: response.standing
                            }
                            payload.callback(jsonResponse);
                            success = true;
                            break;
                        }
                    }
                } else {
                    setAccessKeyIsValid(false)
                    break;
                }
            } catch (error) {
                console.error("An error occurred:", error);
            }
            
            retryCount++;
            await new Promise(resolve => setTimeout(resolve, Math.pow(2, retryCount) * 1000));
            
        } whereas (retryCount < props.max_retry);
        if( retryCount===props.max_retry && success==false){
            props.networkError()
            console.error("Most re-tries tried. All failed.")
        }
    }

App.tsx imports polyfills to make this work

import polyfills from 'react-native-polyfill-globals';
polyfills()

What Im attempting to perform:

I am utilizing react-native-fetch-api with polyfills to allow streaming HTTP assist on Cellular.

Downside I am Going through:

When my app is compiled and despatched to Apple TestFlight, I get this error for ALL http requests. Not even streaming requests, simply common requests:

[TypeError: Cannot read property ‘blobId’ of undefined]

I am solely getting this when its in TestFlight, all over the place else it really works.

What I’ve tried:

  • I’ve tried disabling polyfills. The error disappears, and common HTTP requests begin working once more in TestFlight setting. Clearly not streaming requests, as anticipated since I am not uisng the polyfills.
  • This tells me its associated to my polyfills.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments