首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部署函数时出错代码: 3,函数在加载用户代码时失败。

部署函数时出错代码: 3,函数在加载用户代码时失败。
EN

Stack Overflow用户
提问于 2022-04-19 17:10:46
回答 2查看 736关注 0票数 2

几个月以来,我在这个项目中工作过,我在部署到火力基地方面没有问题。我只是尝试更新一些Web应用程序的角度,这是托管在防火墙。现在,每当我尝试部署时,我都会得到以下错误:

错误:部署函数时出错

函数文件夹中的package.json中的依赖项:

代码语言:javascript
复制
"dependencies": {
    "@sendgrid/mail": "^7.2.1",
    "@types/node": "^14.0.18",
    "egoiSdk": "github:E-goi/sdk-javascript",
    "firebase-admin": "^8.6.0",
    "firebase-functions": "^3.3.0",
    "mailchimp-api-v3": "^1.14.0"
  },

函数文件夹外的一个:

代码语言:javascript
复制
 "dependencies": {
        "@angular/animations": "~8.2.4",
        "@angular/common": "~8.2.4",
        "@angular/compiler": "~8.2.4",
        "@angular/core": "~8.2.4",
        "@angular/forms": "~8.2.4",
        "@angular/platform-browser": "~8.2.4",
        "@angular/platform-browser-dynamic": "~8.2.4",
        "@angular/router": "~8.2.4",
        "@fortawesome/angular-fontawesome": "^0.5.0",
        "@fortawesome/fontawesome-svg-core": "^1.2.27",
        "@fortawesome/free-solid-svg-icons": "^5.12.1",
        "@sendgrid/mail": "^7.2.1",
        "bootstrap": "^4.4.1",
        "firebase": "^8.2.4",
        "firebase-admin": "^9.2.0",
        "firebase-functions": "^3.11.0",
        "jquery": "^3.5.1",
        "mailchimp-api-v3": "^1.14.0",
        "ngx-facebook": "^3.0.0-0",
        "ngx-pagination": "^5.0.0",
        "popper.js": "^1.16.1",
        "rxjs": "~6.4.0",
        "tslib": "^1.11.1",
        "zone.js": "~0.9.1"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "^0.803.24",
        "@angular/cli": "^8.3.25",
        "@angular/compiler-cli": "~8.2.4",
        "@angular/language-service": "~8.2.4",
        "@types/jasmine": "~3.3.8",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~8.9.4",
        "codelyzer": "^5.0.0",
        "jasmine-core": "~3.4.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~4.1.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~2.0.1",
        "karma-jasmine-html-reporter": "^1.5.2",
        "protractor": "^5.4.3",
        "ts-node": "~7.0.0",
        "tslint": "~5.15.0",
        "typescript": "~3.5.3"
    },

和函数日志:

代码语言:javascript
复制
{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":
{"code":3,"message":"Function failed on loading user code. This is likely due to a bug
in the user code. Error message: Error: please examine your function logs to see the 
error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. 
Additional troubleshooting documentation can be found at 
https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit 
https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting 
documentation."},"authenticationInfo": 
{"principalEmail":"example@example.com"},
"serviceName":"cloudfunctions.googleapis.com",
"methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
"resourceName":"projects/my-project/locations/us-central1/functions/newSubscriber"} 

我的函数设置在index.ts上:

代码语言:javascript
复制
admin.initializeApp(functions.config().firebase);
admin.firestore().settings({ timestampsInSnapshots: true });

const defaultClient = egoiSdk.ApiClient.instance;
const Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = "API_KEY";


exports.newSubscriber = functions.firestore.document('subscribers/{subscriberID}')
  .onCreate((snap, context) => {   

    const apiInstance = new egoiSdk.ContactsApi();
    const listId = 1; // Number | ID of the list where the contact belongs
    const contactBaseExtra = new egoiSdk.ContactBaseExtra(
      {
        "base":
        {
          "status": "active",
          "first_name": "Name",
          "language": "pt",
          "email": "example@example.com",
        }
      }
    ); 


    const callback = (error: any, data: any, response: any) => {
      if (error) {
        //console.log('ERRO AQUI');
        //console.error('ERRO AQUI!!!: ', error);
      } else {
        //console.log('API called successfully. Returned data: ' + data);
      }
    };
    apiInstance.createContact(listId, contactBaseExtra, callback);
  });

为什么这么头痛?我已经尝试过我能找到的解决方案了。我删除了两个node_modules文件夹,安装,重新安装,更新版本和什么都没有。一个包裹出了问题,但也解决了问题。我不知道还能做什么。有人对如何解决这个问题有什么建议吗?

任何形式的帮助都是值得感谢的!

编辑:我还没有解决这个问题,但是我用firebase deploy --exclude functions解决了这个问题。

诚挚的问候。

EN

回答 2

Stack Overflow用户

发布于 2022-04-19 23:03:12

根据错误(正如指示的这里 ),如果没有正确指定代码的入口点,即导出的函数名,云函数部署可能会失败。您的源代码必须包含部署中正确指定的入口点函数,无论是通过云控制台还是Cloud。

票数 0
EN

Stack Overflow用户

发布于 2022-11-15 05:14:51

代码语言:javascript
复制
import * as functions from 'firebase-functions';

在我的例子中,我创建了这样一个触发器。

代码语言:javascript
复制
export const sendChatNotifications = functions.database
  .ref('/messages')
  .onWrite(() => {
    console.log('-------sendChatNotifications-----------');
  });

但是下面给出了正确的方法,它对我有效。

代码语言:javascript
复制
exports.newChat = functions.firestore
  .document('messages/{docId}')
  .onWrite((change, context) => {
    console.log('-------sendChatNotifications-----------');
  });

有关更多信息,您可以通过运行此命令来跟踪问题。

火基功能:日志

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71928762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档