具有无效查询字符串段的Firebase功能运行缓慢: [英] Slow running firebase function with Invalid query string segment:

本文介绍了具有无效查询字符串段的Firebase功能运行缓慢:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的firebase函数,该函数正在读取非常少量的数据(小于1kb),但要花将近2秒钟才能完成,并且在日志FIREBASE WARNING: Invalid query string segment:

I have a simple firebase function which is reading a very small amount of data (less than 1kb) but it is taking nearly 2 seconds to complete and has a warning in the logs FIREBASE WARNING: Invalid query string segment:

结果是200 OK,但是显然发生了奇怪的事情,一个

The result is 200 OK, however something strange is clearly going on, a

   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

firebase.json

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

推荐答案

Invalid query string segment警告看起来像最近引入了错误,有望很快得到解决.

The Invalid query string segment warning looks like a recently introduced bug which will hopefully be fixed soon.

这篇关于具有无效查询字符串段的Firebase功能运行缓慢:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆