在转换相对较小的图像 (2mb) 时,我不断收到来自 Cloud Functions for Firebase 的偶发错误。成功后,该函数只需大约 2000 毫秒或更短的时间即可完成,并且根据 Image Magick 文档,我应该不会看到任何问题。
我尝试增加命令的缓冲区大小,这在 Firebase 中是不允许的,并且我尝试寻找替代方法.spawn()
因为这可能会因垃圾过多而减慢速度。什么都不起作用。
您可以在 Firebase 上的 Cloud Function 文件中进行设置。
const runtimeOpts = {
timeoutSeconds: 300,
memory: '1GB'
}
exports.myStorageFunction = functions
.runWith(runtimeOpts)
.storage
.object()
.onFinalize((object) = > {
// do some complicated things that take a lot of memory and time
});
取自此处的文档:
https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation
别忘了然后运行firebase deploy
从您的终端。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)