这是因为 Google Cloud Function 的部署工具在上传文件时会限制上传的文件大小,如果文件过大就会导致上传失败并显示 EOFError。解决此问题的方法是将函数的大小优化到限制范围内。可以尝试以下方法:
zip -r function.zip index.js node_modules/
npm uninstall --save
gcloud functions deploy --source= --entry-point= --runtime= --trigger-http --memory= --timeout=