Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot read property 'blobId' of undefined" from HTTP 204 No Content response #15

Open
kraenhansen opened this issue Apr 26, 2023 · 3 comments

Comments

@kraenhansen
Copy link

kraenhansen commented Apr 26, 2023

When performing a "DEL" request to a server which responds with an HTTP "204 No Content" response, I get the following error:

Cannot read property 'blobId' of undefined

This is a JSON dump of the symbolicated stack:

[
  {
    file: 'my-project-root/node_modules/react-native/Libraries/Blob/BlobManager.js',
    methodName: 'createFromOptions',
    arguments: [],
    lineNumber: 113,
    column: 34,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/react-native-fetch-api/src/BlobResponse.js',
    methodName: 'constructor',
    arguments: [],
    lineNumber: 6,
    column: 51,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/react-native-fetch-api/src/Fetch.js',
    methodName: '__didCompleteNetworkResponse',
    arguments: [],
    lineNumber: 243,
    column: 47,
    collapse: false
  },
  {
    file: null,
    methodName: 'next',
    arguments: [Array],
    lineNumber: null,
    column: null,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/@babel/runtime/helpers/asyncToGenerator.js',
    methodName: 'asyncGeneratorStep',
    arguments: [],
    lineNumber: 3,
    column: 24,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/@babel/runtime/helpers/asyncToGenerator.js',
    methodName: '_next',
    arguments: [],
    lineNumber: 22,
    column: 27,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/@babel/runtime/helpers/asyncToGenerator.js',
    methodName: 'Promise$argument_0',
    arguments: [],
    lineNumber: 27,
    column: 12,
    collapse: false
  },
  {
    file: '/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/5e6w3h5p/arm64-v8a/lib/InternalBytecode/InternalBytecode.js',
    methodName: 'tryCallTwo',
    arguments: [],
    lineNumber: 61,
    column: 9,
    collapse: false
  },
  {
    file: '/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/5e6w3h5p/arm64-v8a/lib/InternalBytecode/InternalBytecode.js',
    methodName: 'doResolve',
    arguments: [],
    lineNumber: 216,
    column: 25,
    collapse: false
  },
  {
    file: '/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/5e6w3h5p/arm64-v8a/lib/InternalBytecode/InternalBytecode.js',
    methodName: 'Promise',
    arguments: [],
    lineNumber: 82,
    column: 14,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/@babel/runtime/helpers/asyncToGenerator.js',
    methodName: 'Promise$argument_0',
    arguments: [],
    lineNumber: 19,
    column: 23,
    collapse: false
  },
  {
    file: null,
    methodName: 'apply',
    arguments: [Array],
    lineNumber: null,
    column: null,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/react-native-fetch-api/src/Fetch.js',
    methodName: 'Fetch',
    arguments: [],
    lineNumber: 254,
    column: 5,
    collapse: false
  },
  {
    file: null,
    methodName: 'apply',
    arguments: [Array],
    lineNumber: null,
    column: null,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/react-native-fetch-api/src/Fetch.js',
    methodName: 'Networking.addListener$argument_1',
    arguments: [],
    lineNumber: 88,
    column: 16,
    collapse: false
  },
  {
    file: null,
    methodName: 'apply',
    arguments: [Array],
    lineNumber: null,
    column: null,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js',
    methodName: 'emit',
    arguments: [],
    lineNumber: 105,
    column: 36,
    collapse: true
  },
  {
    file: null,
    methodName: 'apply',
    arguments: [Array],
    lineNumber: null,
    column: null,
    collapse: false
  },
  {
    file: 'my-project-root/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js',
    methodName: '__callFunction',
    arguments: [],
    lineNumber: 427,
    column: 32,
    collapse: true
  },
  {
    file: 'my-project-root/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js',
    methodName: '__guard$argument_0',
    arguments: [],
    lineNumber: 113,
    column: 26,
    collapse: true
  },
  {
    file: 'my-project-root/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js',
    methodName: '__guard',
    arguments: [],
    lineNumber: 368,
    column: 10,
    collapse: true
  },
  {
    file: 'my-project-root/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js',
    methodName: '__guard$argument_0',
    arguments: [],
    lineNumber: 112,
    column: 17,
    collapse: true
  }
]

Debugging

I removed the comments from some methods in Fetch.js to reveal this:

LOG  fetch __didCreateRequest {"requestId": 10}
LOG  fetch __didReceiveNetworkResponse {"headers": {"Content-Encoding": "gzip", "Date": "Wed, 26 Apr 2023 21:54:56 GMT", "Strict-Transport-Security": "max-age=31536000; includeSubdomains;", "Vary": "Origin", "X-Appservices-Request-Id": "64499db00f4b7d44b52b7ad5", "X-Frame-Options": "DENY"}, "requestId": 10, "status": 204, "url": "http://10.0.2.2:9090/api/admin/v3.0/groups/643fd5800f4b7d44b53802af/apps/64499dae0f4b7d44b52b79d2"}
LOG  fetch __didCompleteNetworkResponse {"didTimeOut": undefined, "errorMessage": null, "requestId": 10}

This shows that contrary to other responses the __didReceiveNetworkData method is never called, which is why this._nativeResponse remains undefined, hence the error.

Workaround

I found that I can work around the issue by passing the extra reactNative: { textStreaming: true } options to the fetch function:

await fetch(url, {
  method: "DELETE",
  reactNative: { textStreaming: true },
});
@meppsilon
Copy link

meppsilon commented Oct 18, 2023

I'm also having this same issue, except it is not limited to "DEL" requests

@wcastand
Copy link

Currently having the issue on production env with expo-notification. since their fetch is based on built-in one, they don't pass the reactNative: { textStreaming: true }, which generate the blobId error on getExpoPushTokenAsync

blobId error is on Ios only,
on android we get a different error msg but the issue is the same.

@ryanlntn
Copy link

ryanlntn commented Aug 9, 2024

I was able to resolve this by updating my polyfill like so:

  polyfillGlobal(
    "fetch",
    () =>
      (...args: Parameters<typeof window.fetch>) =>
        fetch(args[0], { ...args[1], reactNative: { textStreaming: true } }),
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants