Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js Initializer 函数无法在本地环境触发,发布到线上后可以触发 #1095

Open
fanmaomao opened this issue Mar 15, 2021 · 3 comments

Comments

@fanmaomao
Copy link

fanmaomao commented Mar 15, 2021

配置的Initializer函数在本地运行时无法触发,发布到线上后可以触发

配置和日志如下:

template.yml

ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
  Puppeteer-service-screenshot:
    Type: 'Aliyun::Serverless::Service'
    Properties:
      Description: Puppeteer screenshot service
    Puppeteer-screenshot:
      Type: 'Aliyun::Serverless::Function'
      Properties:
        Initializer: demo.initializer
        InitializationTimeout: 180
        Handler: demo.handler
        Runtime: nodejs12
        CodeUri: ./
        MemorySize: 512
        Timeout: 120
      Events:
        httpTrigger:
          Type: HTTP
          Properties:
            AuthType: ANONYMOUS
            Methods:
              - GET
              - POST

demo.js

exports.initializer = function (context, callback) {
    console.log('======> demo.js initializer() ');
    callback(null, "");
}


exports.handler = function (request, response, context) {
    console.log('======> demo.js handler() ');

    response.setStatusCode(200);
    response.setHeader('content-type', 'application/json');
    response.send(JSON.stringify({}))
}

fun local start日志:

using template: template.yml
HttpTrigger httpTrigger of Puppeteer-service-screenshot/Puppeteer-screenshot was registered
        url: http://localhost:8000/2016-08-15/proxy/Puppeteer-service-screenshot/Puppeteer-screenshot/
        methods: [ 'GET', 'POST', 'PUT' ]
        authType: ANONYMOUS


function compute app listening on port 8000!

skip pulling image aliyunfc/runtime-nodejs12:1.9.13...
FC Initialize End RequestId: 6e845f13-b0b7-4872-9195-abdb4673c6e8, Error: Handled function error
FC Invoke Start RequestId: 6e845f13-b0b7-4872-9195-abdb4673c6e8
load code for handler:demo.handler
2021-03-15T05:37:48.650Z 6e845f13-b0b7-4872-9195-abdb4673c6e8 [verbose] ======> demo.js handler() 
FC Invoke End RequestId: 6e845f13-b0b7-4872-9195-abdb4673c6e8
Error: Missing header x-fc-initialization-timeout

RequestId: 6e845f13-b0b7-4872-9195-abdb4673c6e8          Billed Duration: 279 ms         Memory Size: 3938 MB    Max Memory Used: 17 MB

fun deploy函数计算控制台日志:

FC Initialize Start RequestId: c02d7abe-a85c-47d0-9b3c-939d4747bf97
load code for handler:demo.initializer
2021-03-15T05:40:01.316Z c02d7abe-a85c-47d0-9b3c-939d4747bf97 [verbose] ======> demo.js initializer() 
FC Initialize End RequestId: c02d7abe-a85c-47d0-9b3c-939d4747bf97
FC Invoke Start RequestId: c02d7abe-a85c-47d0-9b3c-939d4747bf97
load code for handler:demo.handler
2021-03-15T05:40:01.463Z c02d7abe-a85c-47d0-9b3c-939d4747bf97 [verbose] ======> demo.js handler() 
FC Invoke End RequestId: c02d7abe-a85c-47d0-9b3c-939d4747bf97
@DevDengChao
Copy link
Contributor

DevDengChao commented Apr 6, 2021

See : #1089, #1102

@ITHcc
Copy link

ITHcc commented Apr 23, 2021

See : #1095, #1102

我在本地要如何更新呢

@DevDengChao
Copy link
Contributor

See : #1089, #1102

我在本地要如何更新呢

设置环境变量 FC_DOCKER_VERSION 为 latest
参考: https://github.com/DevDengChao/aliyun-fc-nodejs12-runtime-initializer-not-invoked-sample-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants