FirebaseError: Client uploaded to the wrong offset (262144 of 0). Meaning?

1,343 views
Skip to first unread message

Sebastián Balay

unread,
Nov 4, 2016, 5:14:44 PM11/4/16
to Firebase Google Group
Hi, I'm trying to upload files from a React Native app following this example https://github.com/wkh237/rn-firebase-storage-upload-sample.
It works excellent from Android, but from iOS devices I'm getting this error from Firebase Storage: FirebaseError: Client uploaded to the wrong offset (262144 instead of 0).

What does the error mean? And how can I find a solution to it?
Thanks!

ma...@selbi.io

unread,
Nov 12, 2016, 2:51:03 PM11/12/16
to Firebase Google Group
Hey Sebastián,

I'm hitting the exact same error including the wrong offset value of 262144. Have you had any luck diagnosing this issue?

I've seen intermittent failures with production builds but upload consistently works in development builds (__DEV__==true).

Thanks
Matt

ma...@selbi.io

unread,
Nov 12, 2016, 5:02:18 PM11/12/16
to Firebase Google Group
I believe I have found the issue.

Additional details: 
- I was not running the sample code but rather my own adaptation.
- In my adaptation, I reference firebase.storage in my Firebase module and RNFetchBlob.Blob from my image manipulation module.
- I attached the window.Blob and window.XMLHttpRequest in the image manipulation module.

Key info:
I observed that some app builds would work and others would not. For example, if I could store and image to firebase for a build of the app, all stores would work. If the first attempted store failed, all subsequent stores would also fail. This lead me to believe that the bug was occurring due to was some difference between bundled versions of the app.

I particularly suspected an issue with bundling because I could not reproduce the issue on a development build which is likely different from the bundling for a production build.

I'm not an experienced RN/JS developer but my guess is that the ordering of the modules is non-deterministic. Since I attached Blob and XMLHttpRequest inside a module, it's possible that the binding wasn't properly visible for the other module. (Like I said, I'm _not_ a JS guy so sorry if that's a shit explaination).

Once I moved these lines to my root module, I could not reproduce the bug:
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
window.Blob = RNFetchBlob.polyfill.Blob;

k...@frrand.com

unread,
Nov 14, 2016, 10:10:02 AM11/14/16
to Firebase Google Group
Also getting this issue too. The same exact code worked about 2 weeks ago without issue, which makes me believe that something changed at Firebase..

Another observation:

If I upload a image of smaller size as the initial image (completely black, or some other solid color): all subsequent uploads work (regardless of size).

Moving those lines to my root module did not help in my case. When you meant root module, did you mean index.ios.js?

--

Frrand Inc.
The Hub, 1265 Military Trail
Toronto, ON M1C 1A4

Matthew Dailey

unread,
Nov 14, 2016, 11:50:40 AM11/14/16
to fireba...@googlegroups.com
I was wrong in my prior post. Sorry for the bad write up. I tried 20 or so builds Saturday and it worked but today saw the error again. Yeah, by root module, I meant index.ios. 

Interesting observation about uploading a small image. That actually might be quite helpful for me since I'm upload a fullsize and a 10kb thumbnail image. I'm currently uploading the large image followed by the smaller. 

I'll be investigating more today (I'm in SF) and I'll report back. My plan going forward to work around this was to catch this error and compress larger images to below 262144 bytes.

The frustrating part is that I can't seem to consistently reproduce this issue. Are you seeing consistent failures as long as you don't submit the smaller image first? 

I just migrated to use Firebase Storage last week (around Nov 5) and we haven't put it into production yet so I don't have any good historical data about this working. It seemed to work until just a few days ago, not sure when i first saw the issue.



--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/ejc4hbwUNy4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/2c7d699e-a91a-4dba-b629-15cc83f06448%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Dailey

unread,
Nov 14, 2016, 1:39:38 PM11/14/16
to fireba...@googlegroups.com
I'm now able to reproduce the issue regularly as well as the 'fix' of uploading a small image first.

Steps I took to standardize my process:
- full uninstall of app between trials
- use the same image instead of capturing a new one with every trial

Fortunately for me, uploading the thumbnail prior to uploading the full size image is sufficient.

Other thoughts:
- I can't rule out that this isa firebase server side issue but that seems unlikely because of the fact that upload ordering seems to help. That makes me think the client needs some initialization which happens successfully when a small file is uploaded.
- I can't rule out that this is a firebase client issue because I've only recently added file upload.
- I can't rule out that this is a react-native-fetch-blob issue but that seems unlikely since I imagine that package is more broadly used. Potentially it's an issue at the firebase client / RNFetchblob interface and not a specific bug in either package.
- Could be an iOS issue although I have not tried on android but will be working on porting our app this week. We'll see how it goes and I'll respond here.

In the end, I'd put my money on a weirdness at the interface between react-native-fetch-blob and firebase. I'd bet on different interpretations of some multipart upload specification.

@Ken, thanks for the work around and lemme know if I can help your investigation in any way.

Florian Norbert Bepunkt

unread,
Nov 20, 2016, 2:55:59 PM11/20/16
to Firebase Google Group
I'm also getting this error: wrong offset (262144 of 0) – I have no idea what this error is supposed to mean. Have you been able to solve this?

William Candillon

unread,
Nov 22, 2016, 11:02:28 AM11/22/16
to Firebase Google Group
I'm experiencing the same issue without using react-native-fetch-blob (I'm sending the image as a base64 string). 

Kind regards,

William

Spencer Phippen

unread,
Nov 22, 2016, 7:51:28 PM11/22/16
to Firebase Google Group
Firebase Storage JS dev here.

Disclaimer: at time of writing, we don't officially support uploads with our library, binary or string, in React Native. All the other Storage functionality should work though - for example, we fixed some Android-specific React Native issues in 3.6.1 to ensure this.

Also, for anyone using Firebase JS version 3.6.1, there's currently another bug in react-native-fetch-blob that makes Firebase Storage uploads unusable with react-native-fetch-blob. It looks separate from this issue, but I still wanted to bring it up in case anyone here is experiencing the same problem.

Regarding the "wrong offset (262144 instead of 0)" error: I haven't been able to reproduce it, but I have an idea of why it might be happening. The Firebase Storage library uses the Blob.size property when it uploads files, and since the react-native-fetch-blob Blob polyfill doesn't provide an accurate .size value, I could see it causing problems[1].

Here's some code I ran (react-native-fetch-blob 0.10.0):

import RNFetchBlob from 'react-native-fetch-blob'

window.Blob = RNFetchBlob.polyfill.Blob

let blob = new Blob(['thisisablob']); // size should be 11

console.log('size1: ' + blob.size);

blob.onCreated(function() {

  console.log('size2: ' + blob.size);

});


The actual size of the blob is 11, but neither of the log statements print that value:

2016-11-22 16:19:22.301 [info][tid:com.facebook.react.JavaScript] size1: undefined

2016-11-22 16:19:22.308 [info][tid:com.facebook.react.JavaScript] size2: 0


Not sure if fixing the size property would fix 100% of the problems, but I think it's related to this bug.
If anyone can produce and share an MCVE for this bug, that would also be helpful. As mentioned above, I haven't been able to reproduce it.

Finally, to William Candillon: I wouldn't expect base64 string uploads to work at all without a third-party library like react-native-fetch-blob. What platform are you using? And are you still patching Blob and XMLHttpRequest somehow?

Thanks,
Spencer P

[1] Large files get sliced and uploaded in multiple pieces - parts of this code might break if blobs don't report their size properly. The error message "wrong offset (262144 instead of 0)" indicates a piece of a file was uploaded in the wrong place.

William Candillon

unread,
Nov 23, 2016, 11:09:48 AM11/23/16
to fireba...@googlegroups.com
Dear Spencer,

Thank you so much for this information. It solved the issue for me.
Sir, you have made my day :)

Kind regards,

William
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Firebase Google Group" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/firebase-talk/ejc4hbwUNy4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> firebase-tal...@googlegroups.com.
> To post to this group, send email to fireba...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/firebase-talk/9383508c-84a5-417c-91f0-1a5321287c82%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages