Skip to content

Problems while individually packaging #255

Open
@k-ogawa-1988

Description

@k-ogawa-1988

Versions:

This plugin: 4.0.0

Operating System:          darwin
Node Version:              14.16.1
Framework Version:         2.39.1 (local)
Plugin Version:            4.5.3
SDK Version:               4.2.2
Components Version:        3.9.1

Problem no.1

When package.artifact is specified as empty string, sls package works fine.

# serverless.yml

package:
  individually: true
  patterns:
    - '!.gitignore'
    - '!node_modules/**'
    - '!package.json'
    - '!yarn.lock'
  artifact: ''

But sls package fails when package.artifact is not specified.

# serverless.yaml

package:
  individually: true
  patterns:
    - '!.gitignore'
    - '!node_modules/**'
    - '!package.json'
    - '!yarn.lock'

Error

  TypeError: Cannot read property 'split' of undefined
      at GooglePackage.compileFunctions (/path/to/cloud_functions/node_modules/serverless-google-cloudfunctions/package/lib/compileFunctions.js:13:39)
      at GooglePackage.tryCatcher (/path/to/cloud_functions/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/path/to/cloud_functions/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/path/to/cloud_functions/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/path/to/cloud_functions/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/path/to/cloud_functions/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/path/to/cloud_functions/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/path/to/cloud_functions/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/path/to/cloud_functions/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:461:21)

/package/lib/compileFunctions.js

image

Problem no.2

Under functions.func_name, package causes validation warning when sls package even if there's an official document.

# serverless.yml

package:
  individually: true
  patterns:
    - '!.gitignore'
    - '!node_modules/**'
    - '!package.json'
    - '!yarn.lock'
    - '!src/**'
  artifact: ''

functions:
  listUsers:
    package:
      patterns:
        - 'src/list_users/**'
    handler: list_users
    memorySize: 128
    timeout: 60s
    events:
      - http: path

Warning

Serverless: Configuration warning at 'functions.listUsers': unrecognized property 'package'
Serverless:  
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation

Note : generated .zip files looks fine.

Problem no.3

sls deploy with configuration below (including package.individually = true, package.artifact = '' and functions.func_name.package) causes error.

# serverless.yml

package:
  individually: true
  patterns:
    - '!.gitignore'
    - '!node_modules/**'
    - '!package.json'
    - '!yarn.lock'
  artifact: ''

functions:
  listUsers:
    package:
      patterns:
        - 'src/list_users/**'
    handler: list_users
    memorySize: 128
    timeout: 60s
    events:
      - http: path

Error

(no stacktrace)

yarn run v1.22.10
$ /path/to/cloud_functions/node_modules/.bin/sls deploy
Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
             - GoogleLogs for "count"
            Please report this issue in plugin issue tracker.
            Starting with next major release, this will be communicated with a thrown error.
            More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Configuration warning at 'functions.listUsers': unrecognized property 'package'
Serverless:  
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:  
Serverless: Deprecation warning: Starting with next major, Serverless will throw on configuration errors by default. Adapt to this behavior now by adding "configValidationMode: error" to service configuration
            More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling function "listUsers"...
Serverless: Uploading artifacts...
 
 Error ---------------------------------------------------
 
  Error: ENOENT: no such file or directory, open ''
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.16.1
     Framework Version:         2.39.1 (local)
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.9.1
 
Serverless: Artifacts successfully uploaded...
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Note: when turning off indiviaullly packaging, deploy works well but it may contain unused files (e.g. other function's code).

How can I work around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions