serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
783 stars 223 forks source link

Doesn't support new Docker `image` syntax #227

Open smcelhinney opened 3 years ago

smcelhinney commented 3 years ago

As per https://www.serverless.com/blog/container-support-for-lambda, you can now use the image property in function instead of a handler.

Error

  Type Error ---------------------------------------------

  TypeError: Cannot read property 'split' of undefined

is thrown at https://github.com/prisma-labs/serverless-plugin-typescript/blob/master/src/typescript.ts#L51 because it expects a handler property to be defined.

Required if you have (like I do) a mix of typescript handlers and Docker images in the same application.

smcelhinney commented 3 years ago

If you've found this issue from a search engine, a (less-than-ideal) solution I've used for deployment is to create a separate serverless.docker.yml file with your Docker based deployments, and run serverless deploy -c serverless.docker.yml

alanwilter commented 2 years ago

Sorry, I found this issue by search... and I was doing, presumably, exactly what you said, yet, this not working for me:

Test based on example (which is awfully outdated).

Dockerfile:

FROM public.ecr.aws/lambda/nodejs:14
COPY handler.ts ./
CMD ["handler.hello"]

serverlessD.yml:

service: serverless-example
frameworkVersion: "2 || 3"
plugins:
  - serverless-plugin-typescript

provider:
  name: aws
  # runtime: nodejs14.x
  ecr:
    images:
      appimage:
        path: ./
  region: eu-west-2
  lambdaHashingVersion: 20201221

functions:
  hello:
    # handler: handler.hello
    image:
      name: appimage
    events:
      - http:
          path: hello
          method: get

Then:

$ sls deploy -s test -c serverlessD.yml

Serverless: Compiling with Typescript...

 Type Error ----------------------------------------------

  TypeError: Cannot read property 'split' of undefined
...

What am I doing wrong please?

jamesjoung commented 2 years ago

still happening anyone have work around? It does look like the plugin is looking for handler property, but for instance with function that is mapped to docker image does not have this property. Adding handler property with image gets error on serverless deploy.

Rhysjc commented 1 year ago

Add a specific runtime for your function that use the image. If you set it to python3.9 for example, the typescript plugin won't run against it. You may be able to set this to an empty string, but my container does actually use python 3.9

nathanbbarton commented 1 year ago

Any luck resolving this issue running into it myself now, switching from a handler to image.

allavytalize commented 8 months ago

Has any progress been made on this? This bug makes it impossible to use ECR images with typescript lambdas in serverless.

demi-encentral commented 7 months ago

Trying in 2024 and the error seems to still be present

douglasgsouza commented 7 months ago

I have the same error here when defining a function that uses image instead of handler.

demi-encentral commented 7 months ago

@douglasgsouza I was able to deploy my app by removing the plugin from my project and building it with tsc