首页 > 解决方案 > 捕获错误时;在 Firebase 中获取 error.message 作为 INTERNAL

问题描述

requestForm.addEventListener("submit", (e) => {
e.preventDefault();

const addRequest = firebase.functions().httpsCallable("addRequest");
addRequest({
  text: requestForm.request.value,
})
  .then(() => {
    requestForm.reset();
    requestForm.querySelector(".error").textContent = "";
    requestModal.classList.remove("open");
  })

   //Error is caused beacuse of this
  .catch((error) => {
    requestForm.querySelector(".error").textContent = error.message;
  });


});

函数日志错误

Unhandled error RangeError: Maximum call stack size exceeded
    at getIteratee (/srv/node_modules/lodash/lodash.js:5945:25)
    at Function.map (/srv/node_modules/lodash/lodash.js:9580:31)
    at encode (/srv/node_modules/firebase-functions/lib/providers/https.js:177:18)
    at /srv/node_modules/lodash/lodash.js:13427:38
    at /srv/node_modules/lodash/lodash.js:4925:15
    at baseForOwn (/srv/node_modules/lodash/lodash.js:2990:24)
    at Function.mapValues (/srv/node_modules/lodash/lodash.js:13426:7)
    at encode (/srv/node_modules/firebase-functions/lib/providers/https.js:183:18)
    at arrayMap (/srv/node_modules/lodash/lodash.js:639:23)
    at Function.map (/srv/node_modules/lodash/lodash.js:9580:14) 
addRequest
Function execution took 309 ms, finished with status code: 500

该函数应该检查 firebase 中的正常 HTTPS 错误,例如“未经身份验证”和“无效参数”,但得到了INTERNAL ERROR

虽然做firebase服务它仍然捕获错误但是使用firebase部署它甚至没有进入catch函数它显示error.message为“INTERNAL”?这意味着什么

标签: javascriptfirebasegoogle-cloud-functions

解决方案


推荐阅读