You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"FirebaseError: Firebase Storage: An unknown error occurred ... (storage/unknown)" when using resume()/resume()/cancel() Methods on resumable UploadTask while on "Demo" emulator
#5412
Closed
simenness opened this issue
Jan 11, 2023
· 3 comments
· Fixed by #5425
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8" /><title>Firebase Storage Emulator Demo</title><style>html {
font-family:"Roboto", sans-serif;
color:#999;
background-color:#222;
}
</style></head><body><h1>Firebase Storage Emulator Demo</h1><p>
This is a demo of the Firebase Storage Emulator. It is a simple web app
that uploads files to Firebase Storage and lists the uploaded files.
</p><div><inputtype="file" id="file" /><spanid="state"></span></div><div><buttonid="upload">Upload</button><buttonid="pause">Pause</button><buttonid="resume">Resume</button><buttonid="cancel">Cancel</button></div><divid="files"></div></body><scripttype="module">import{initializeApp}from"https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js";import{getStorage,ref,uploadBytesResumable,getDownloadURL,connectStorageEmulator,}from"https://www.gstatic.com/firebasejs/9.15.0/firebase-storage.js";// Firebase configurationconstfirebaseConfig={projectId: "demo-ember",appId: "demo",apiKey: "demo",authDomain: "demo",storageBucket: "demo",};// Initialize FirebaseinitializeApp(firebaseConfig);// Use the Firebase Storage emulatorconnectStorageEmulator(getStorage(),"localhost",9199);// Buttonsconstupload=document.getElementById("upload");constpause=document.getElementById("pause");constresume=document.getElementById("resume");constcancel=document.getElementById("cancel");conststateValue=document.getElementById("state");// Upload button click handlerupload.addEventListener("click",(e)=>{// Get the fileconstfile=document.getElementById("file").files[0];// Create a storage refconststorageRef=ref(getStorage(),file.name);// Upload file and metadata to the object 'images/mountains.jpg'constuploadTask=uploadBytesResumable(storageRef,file);// Pause button click handlerpause.addEventListener("click",(e)=>{// console log that the user clicked the pause button, and make the log text amberconsole.log("%cUser clicked pause button","color: orange");uploadTask.pause();});// Resume button click handlerresume.addEventListener("click",(e)=>{console.log("%cUser clicked resume button","color: orange");uploadTask.resume();});// Cancel button click handlercancel.addEventListener("click",(e)=>{console.log("%cUser clicked cancel button","color: orange");uploadTask.cancel();});// Listen for state changes, errors, and completion of the upload.uploadTask.on("state_changed",(snapshot)=>{constprogress=(snapshot.bytesTransferred/snapshot.totalBytes)*100;console.log("Upload is "+progress+"% done");switch(snapshot.state){case"paused":
stateValue.innerHTML="Paused";console.log("Upload is paused");break;case"running":
stateValue.innerHTML="Running";console.log("Upload is running");break;}},(error)=>{stateValue.innerHTML="ERROR";console.log(error);},()=>{stateValue.innerHTML="Complete";console.log("upload commplete");});});</script></html>
[REQUIRED] Steps to reproduce
Use the HTML file above to upload a file to the Emulator, then hit pause before it's finished.
Emulator is simply running from... firebase emulators:start --project demo-ember
[REQUIRED] Expected behavior
I'd expect the uploadTask to be paused/resumed/canceled when the methods are used.
[REQUIRED] Actual behavior
UploadTasks throw FirebaseError: Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown) when the pause()/resume()/cancel() method(s) are used.
Just tested with firebase@9.7.0,
like the mentioned issue firebase/firebase-js-sdk#6935,
pausing works fine... just as mentioned in that issue (firebase/firebase-js-sdk#6935 (comment)),
but resuming fails with FirebaseError: Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown) like it does with pause(), resume() and cancel() on firebase@9.15.0
Edit: Added cancel() at the end after testing again.
Edit: words?
[REQUIRED] Environment info
firebase-tools: 11.20.0
Platform: Windows
[REQUIRED] Test case
[REQUIRED] Steps to reproduce
Use the HTML file above to upload a file to the Emulator, then hit pause before it's finished.
Emulator is simply running from...
firebase emulators:start --project demo-ember
[REQUIRED] Expected behavior
I'd expect the uploadTask to be paused/resumed/canceled when the methods are used.
[REQUIRED] Actual behavior
UploadTask
s throwFirebaseError: Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown)
when the pause()/resume()/cancel() method(s) are used.firebase-debug.log
ui-debug.log
Edit: made Expected & Actual behavior easier to understand.
The text was updated successfully, but these errors were encountered: