具有无效查询字符串段的慢速运行firebase功能:

时间:2018-02-16 18:07:18

标签: javascript firebase firebase-realtime-database google-cloud-functions firebase-hosting

我有一个简单的firebase函数,它读取的数据量非常少(小于1kb),但是需要将近2秒才能完成并在日志中显示警告FIREBASE WARNING: Invalid query string segment:

结果是200 OK,但是显然有些奇怪的事情,

   import express from 'express';
import * as functions from "firebase-functions"
const cors = require('cors')();
const api = express();

 const getJob = async (req, res) => {
    const { organisation, job } = req.params

    console.log("READING", req.params)
    console.log("one", `careers/jobs/${organisation}/${job}`)

    const jobContent = await admin.database().ref(`careers/jobs/${organisation}/${job}`).once("value")

    if (!jobContent) {
        res.sendStatus(404)
    }

    console.log("two")
    const descriptionContent =await admin.database().ref(`careers/descriptions/${organisation}/${job}`).once("value")

    return res.send({
        ...jobContent.val(),
        description: descriptionContent && descriptionContent.val()
    })

}


api.use(cors);

api.get('/careers/:organisation/jobs/:job', getJob)


export const careersApi = functions.https.onRequest(api)

firebase.json

    {
  "functions": {
    "source": "build"
  },
  "hosting": {
    "public": "public",
    "rewrites": [
      {
        "source": "/careers/**",
        "function": "careersApi"
      }
    ]
  }
}

1 个答案:

答案 0 :(得分:0)

Invalid query string segment警告看起来像recently introduced bug,希望很快得到解决。