firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.76k stars 873 forks source link

getStream() function has error: stream.pipe is not a function #8303

Open aldofebriii opened 2 weeks ago

aldofebriii commented 2 weeks ago

Operating System

Sonoma 14.5

Browser Version

125.0.6

Firebase SDK Version

10.12.2

Firebase SDK Product:

Storage

Describe your project's tooling

Node JS App with express framework.

Describe the problem

I create the function to get the NodeJS.ReadableStream from firebase/storage getStream() function. I passed the correct reference already, but the error said that :

TypeError: stream.pipe is not a function
    at /Users/aldofebri/Documents/GitHub/pskc-main-api/node_modules/@firebase/storage/dist/index.node.cjs.js:2936:32
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The error is coming from the code :

static streamBuffer(filename: string){
        const fileRef = ref(this.storage, "pdf" + "/" + filename);
        const stream = getStream(fileRef);
        stream.on('error', (err) => console.log(err));
        stream.on('data', (data) => console.log(data));
}

If i'im using the reguler getBytes() like below, the code will work.

async fetchBuffer(filename: string){
        const fileRef = ref(this.storage, "pdf" + "/" + filename);
        return await getBytes(fileRef);
};

Steps and code to reproduce issue

streamBuffer(filename: string){
        const fileRef = ref(this.storage, "pdf" + "/" + filename);
        const stream = getStream(fileRef);
        stream.on('error', (err) => console.log(err));
        stream.on('data', (data) => console.log(data));
}
TypeError: stream.pipe is not a function
    at /Users/aldofebri/Documents/GitHub/pskc-main-api/node_modules/@firebase/storage/dist/index.node.cjs.js:2936:32
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
dlarocque commented 2 weeks ago

Hi, thanks for submitting this issue! I was able to successfully reproduce the issue, and have triaged it as a bug.