-
Notifications
You must be signed in to change notification settings - Fork 955
Closed
Labels
Description
Describe your environment
- Operating System version: Windows 10
- Browser version: N/A (Node.js 14)
- Firebase SDK version: 8.10.0
- Firebase Product: storage
Describe the problem
Steps to reproduce:
- Simulate network error such as disconnect from network, blocking DNS server, blocking outgoing traffic, etc.
- Execute storage API such as
getMetadata()
orgetDownloadURL()
. - Unhandled promise rejection is thrown. A sample console log is at below. My expected result is throwing
FirebaseError
with codestorage/retry-limit-exceeded
.
C:\Users\VCD\Developer\playground>node --unhandled-rejections=throw fbstorage-bug.js
C:\Users\VCD\Developer\playground\node_modules\node-fetch\lib\index.js:1461
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
^
FetchError: request to https://firebasestorage.googleapis.com/v0/b/xxxxxxxxxxxxxxxxx.appspot.com/o/image.png failed, reason: getaddrinfo ENOTFOUND firebasestorage.googleapis.com
at ClientRequest.<anonymous> (C:\Users\VCD\Developer\playground\node_modules\node-fetch\lib\index.js:1461:11)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
type: 'system',
errno: 'ENOTFOUND',
code: 'ENOTFOUND'
}
Relevant code:
'use strict'
const firebase = require('firebase/app')
require('firebase/storage')
const app = firebase.initializeApp({
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
projectId: 'xxxxxxxxxxxxxxxxx',
storageBucket: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
messagingSenderId: 'xxxxxxxxxxxx',
appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
})
const storage = app.storage()
// Remember to disconnect the network before running
;(async () => {
const ref = storage.ref('/image.png')
const rtv = await ref.getMetadata()
console.log(rtv)
console.log('END')
})().catch(error => {
console.log('EXCEPTION')
if (error.stack) {
console.error(error.stack)
} else {
console.error(error)
}
}).finally(async () => {
await app.delete()
})