serverless-webpack 5.5.0 attempts to run Webpack on container images which are not JavaScript

Created on 12 May 2021  路  13Comments  路  Source: serverless-heaven/serverless-webpack

This is a Bug Report

Description

For bug reports:

  • What went wrong?

serverless-webpack is stopping me from deploying lambda containers as part of my service that are not

  • What did you expect should have happened?

it should not have touched them as they're not relevant to webpack

  • What was the config you used?

N/A

I assume this is related to https://github.com/serverless-heaven/serverless-webpack/pull/723, which I can see the sense in - however, I can't see a way to say "this isn't a container image that Webpack cares about" and hence ignore that lambda in the service definition. Ideally there'd be an option to opt in/out of either Webpack's involvement in particular functions, or container functions as a whole as not all container functions are guaranteed to be part of the service.

Additional Data

$ /Users/chris/Code/report-support/node_modules/.bin/serverless deploy -v --stage dev
Serverless: Using configuration:
{
  "webpackConfig": "api/webpack.config.js",
  "includeModules": {
    "forceInclude": [
      "pg"
    ]
  },
  "packager": "yarn",
  "keepOutputDirectory": true,
  "packagerOptions": {},
  "concurrency": 12
}

 Serverless Error ----------------------------------------

  No matching handler found for 'apollo' in 'XXX'. Check your service definition.

  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.41.1 (local)
     Plugin Version:            4.6.0
     SDK Version:               4.2.2
     Components Version:        3.9.2
bug

All 13 comments

For what I understand you are mixing both container and regular JavaScript function in the same serverless config?
Any chance to share a short config to reproduce?

service: report-support

provider:
  name: aws
  region: eu-west-2
  runtime: nodejs12.x
  stage: ${opt:stage, 'dev'}
  versionFunctions: false

plugins:
  - serverless-webpack

functions:
  server:
    image:
      uri: ${env:DOCKER_IMAGE}
      entryPoint:
        - /app/node_modules/.bin/aws-lambda-ric
      command:
        - apollo.lambda
    role: LambdaGraphQlRole

  migrate:
    handler: db/migrate.up
    role: LambdaGraphQlRole

  rollback:
    handler: db/migrate.back
    role: LambdaGraphQlRole

custom:
  webpack:
    webpackConfig: api/webpack.config.js
    includeModules:
      forceInclude:
        - pg
    packager: yarn
    keepOutputDirectory: true

Could you test again using the 5.5.1? Thanks 馃檹

Sadly not:

  Serverless Error ----------------------------------------

  No matching handler found for 'apollo' in '/builds/culture-shift/report-support'. Check your service definition.

From where the apollo coming from? I can't see a reference to it in the serverless.yml you shared.

in the definition of the server function, I would assume it's looking at the command of the lambda

Could you explain me what apollo.lambda is referencing to?

According to what was done here https://github.com/serverless-heaven/serverless-webpack/pull/723 and how it is supposed to work here, there should be a apollo.js file which export a lambda function. Isn't?

apollo.lambda is the command passed to the container image. The problem seems to be that it's incorrectly being interpreted as a JavaScript function, so it's looking for a function called lambda inside an apollo.js file - but that's not the case. It's just the command passed to the container. The problem appears to be serverless-webpack is trying to build it, but it's not a container image that Serverless is building itself (because the image has a uri field, it refers to an externally built image, not one built by Serverless). Ideally serverless-webpack shouldn't be trying to get involved in container images that the serverless framework isn't building

@cnorthwood could you check my attached PR? I've skipped off function when image.uri is defined.

Unfortunately that doesn't seem to have changed anything

You still have the same error when using my PR?
I've tried locally using a simple function and it worked, with my PR I don't have the error anymore.

functions:
  server:
    image:
      uri: http://localhost
      command:
        - apollo.lambda

with apologies, it looks like I failed to change to the right branch - yes, that appears to be correct now

Good news!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitttttten picture bitttttten  路  4Comments

jmparsons picture jmparsons  路  5Comments

bebbi picture bebbi  路  3Comments

timoangerer picture timoangerer  路  3Comments

taschmidt picture taschmidt  路  4Comments