mrousavy / react-native-blob-jsi-helper

A React Native library for accessing an ArrayBuffer of a Blob instance.
MIT License
131 stars 8 forks source link

Value is undefined, expected an object #6

Closed mlecoq closed 1 year ago

mlecoq commented 2 years ago

Hi,

during my development I have a strange issue after hot reloading (on Android - with hermes) on calling getArrayBufferForBlob:

Value is undefined, expected an object

I have to restart metro after any code change

mlecoq commented 2 years ago

To precise, it appears not on every reload, just when there is an issue in last edited code

mlecoq commented 2 years ago

I close it, I am no more able to reproduce it

ArkanRomanPango commented 2 years ago

@mlecoq I also reproduce it. image

alexstanbury commented 1 year ago

I'm seeing this problem too, so far only tested on iOS 16.4 - iPhone XR and iPad Simulator. If code is hot reloaded the app is reloaded (either by pressing r in terminal or because it can't hot reload), I get this error until I force quit the app and reopen, at which point all is good in the world until the next reload. Makes using this library while developing pretty painful.

Here's my code:

const blob = await fetch(url).then(r => r.blob());
const arrayBuffer = getArrayBufferForBlob(blob);
// error here

@mrousavy can this be reopened please? I'll knock up a minimal repro in the meantime.

mlecoq commented 1 year ago

@alexstanbury waiting for your repro !

alexstanbury commented 1 year ago

I realised it doesn't happen when hot reloading code, but does when app full reloads.

Repro here: https://github.com/alexstanbury/BlobJsiRepro

hannojg commented 1 year ago

Love the reproduction steps 😄 thank you so much for providing a reproduction 😊

mrousavy commented 1 year ago

Thanks for the repro! Can you throw a breakpoint there in Xcode and step through one by one and let me know in which line it fails?

https://github.com/mrousavy/react-native-blob-jsi-helper/blob/1d016b62e43ce44b4c5d0a810335567d9992e023/ios/BlobJsiHelper.mm#L36

alexstanbury commented 1 year ago

Sure, it fails on this line:

https://github.com/mrousavy/react-native-blob-jsi-helper/blob/1d016b62e43ce44b4c5d0a810335567d9992e023/ios/BlobJsiHelper.mm#L44

alexstanbury commented 1 year ago

Hopefully this screenshot helps a bit, this seems to be the exact place it's dying. This is a blocker for me as I'm pretty sure I'm gonna run into this issue when the app gets reloaded after a code push update.

Screenshot 2023-07-06 at 17 16 32

mrousavy commented 1 year ago

Ah hold on I got a fix

mrousavy commented 1 year ago

Done, released in v0.3.1!

alexstanbury commented 1 year ago

Confirming fix works, thank you! 🍻