Unstoppable error when uploading image that doesn't exist

#1

When trying to upload an image (that was stored using ImagePicker) to a server using fetch, up pops a file-not-found error. This is to be expected, and my app could handle it. But the error pops up as a big red non-js error in dev mode on iOS (see screenshot). In prod-mode on iOS the error probably happens but is silently ignored.

How can I catch this error? Or, failing that, detect whether the file exists to avoid the error? On production, how can I detect whether this sort of error is happening? Is there any way to get general logs or error logs from running the published app on my phone?

Here’s the code: https://github.com/seveneightn9ne/pottery-log/blob/master/ImageUploader.js#L31

For some context, we’re sending to a server because of this: https://forums.expo.io/t/images-from-imagepicker-disappear-occasionally/392 . The file doesn’t exist because the cache disappeared before it had the chance to upload.

#2

Can you try creating a small reproduction with https://snack.expo.io/? It’s a little hard to tell exactly what’s happening from looking at the current code. Here’s an example of an image upload app that works for us: https://github.com/expo/image-upload-example

#3

Sure! I’m not very familiar with snack, do you have that image-upload-example as a snack? It should be a small tweak from it.

#4

It’s the same as a regular Expo app but just one file, you should be able to copy the code over. Just makes it easier for us to run it.