System on firebase functions always have problems that code start.
https://medium.com/@siriwatknp/cold-start-workaround-in-firebase-cloud-functions-8e9db1426bd3
So
google office https://firebase.google.com/docs/functions/networking
const http = require('http'); const functions = require('firebase-functions'); // Setting the `keepAlive` option to `true` keeps // connections open between function invocations const agent = new http.Agent({keepAlive: true}); exports.function = functions.https.onRequest((request, response) => { req = http.request({ host: '', port: 80, path: '', method: 'GET', agent: agent, // Holds the connection open after the first invocation }, res => { let rawData = ''; res.setEncoding('utf8'); res.on('data', chunk => { rawData += chunk; }); ... Two line let me confused. Not only me. const agent = new http.Agent({keepAlive: true}); agent: agent, // Holds the connection open after the first invocation Some guy same me.
...