Note: i've set this up with Firebase Functions.
Emulator
When my firebase function takes more than 5 seconds, it returns
{ code: "ECONNRESET" }
The console shows:
functions: Your function timed out after ~300s. To configure this timeout, see
(although it endured only 5 seconds)
No matter the amount of timeoutSeconds set below.
const functions = require("firebase-functions");
const cors = require('cors')({
  origin: true,
});
exports.app = functions.runWith({
  timeoutSeconds: 300
}).https.onRequest((req, res) => {
  cors(req, res, () => {
    setTimeout(() => res.send({result: 'success'}), 5000);
  });
});
This problem occurs in the emulator firebase emulators:start --only functions
Also strange behavior in the console when the server responds after 4 seconds. It says after five seconds that it times out after 300 sec, although the app already finished:
i  functions: Beginning execution of "app"
i  functions: Finished "app" in 4102.929386ms
⚠  functions: Your function timed out after ~300s. To configure this timeout, see
      https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation.
⚠  Your function was killed because it raised an unhandled error.
Deployed When I deploy it, then the url shows this result, although I use cors
Error: Forbidden
Your client does not have permission to get URL /app from this server.
The versions in package.json
  "dependencies": {
    "firebase-admin": "^10.3.0",
    "firebase-functions": "^3.18.0"
  },
The documentation for: runWith
 
    