firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 915 forks source link

Node.js HTTP Function + Cloud Storage time out in emulator #2555

Open loucou opened 3 years ago

loucou commented 3 years ago

[REQUIRED] Environment info

firebase-tools: 8.7.0

Platform: Windows

[REQUIRED] Test case

The function on the server:

module.exports = functions.region("europe-west3").https.onRequest((req, res) => {
    const bucket = admin.storage().bucket();
    const fileStream = bucket.file("test/launch.jpg").createReadStream();

    fileStream.on("data", chunk => res.write(chunk));
    fileStream.on("end", () => res.end());
    fileStream.on("response", r => {
        res.set({
            "content-type": r.headers["content-type"],
            "content-length": r.headers["content-length"],
            "content-disposition": "inline",
        });
    });

    res.on("close", () => res.status(200).send());
    res.on("error", () => res.status(500).send());
});

The client:

`

loading...

`

[REQUIRED] Steps to reproduce

Run the emulators, open the web page containing the img tag

[REQUIRED] Expected behavior

The function executes and finishes quickly

[REQUIRED] Actual behavior

The function executes fine and returns the image, but then it displays time out after 60s in the emulator logs. It only happens with emulators, not when run normally, and not when streaming a local file instead of a Cloud Storage file.

samtstern commented 3 years ago

@loucou thanks for the detailed repro!