提问人:albertoivo 提问时间:11/14/2023 最后编辑:albertoivo 更新时间:11/17/2023 访问量:39
错误:在 Firebase 可调用函数中,多次提取和 Promise.all() 超出了重定向计数
Error: redirect count exceeded with many fetch and Promise.all() in a Firebase callable function
问:
当我在firebase可调用函数中执行此操作时:
for (const origin of originList) {
for (const destiny of destinyList) {
// mount the url
const respPromise = fetch(url)
.then((resp) => resp.json())
.then((data) => {
// manipulate a big JSON (2000 lines or more each one)
})
fetchPromises.push(respPromise)
}
}
await Promise.all(fetchPromises)
两个列表都可以有 10 个以上的寄存器,因此提取将运行数百次。 它非常不稳定,有时我会得到正确的结果,但大多数时候我得到:
Unhandled error TypeError: fetch failed
...
cause: Error: redirect count exceeded
at makeNetworkError (node:internal/deps/undici/undici:4801:35)
at httpRedirectFetch (node:internal/deps/undici/undici:9659:16)
at httpFetch (node:internal/deps/undici/undici:9632:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async schemeFetch (node:internal/deps/undici/undici:9535:18)
at async node:internal/deps/undici/undici:9409:20
at async mainFetch (node:internal/deps/undici/undici:9399:20)
at async httpFetch (node:internal/deps/undici/undici:9632:22)
at async schemeFetch (node:internal/deps/undici/undici:9535:18)
at async node:internal/deps/undici/undici:9409:20
我不知道它是否是纯 javascript 代码,我可以,但重构代码或 firebase 无法在可调用函数中调用这么多 fetch。
有什么建议吗?
答:
0赞
albertoivo
11/17/2023
#1
问题是我调用Firebase函数的编码。
我在前端的函数中实例化了Firebase可调用函数。handleSubmit()
当我将其传输到外部时,错误已经弯曲:
import { getFunctions, httpsCallable } from 'firebase/functions'
const functions = getFunctions()
const callableReturnMessage = httpsCallable(functions, 'myFunction')
评论