Exit 254 lambda error with no extra explanations

0

I have a Lambda function running a docker container. The docker container runs without issue localy but on AWS lambda all I get is a "Error: Runtime exited with error: exit status 254" message without any other output. I can mention that I am coding on a Mac with M1 architecture, the docker image is based off node:18-buster-slim with aws-lambda-ric baked into it and chromium installed. I am deploying in SAM with x86 as target architecture since was lambda on arm64 doesn't have the option to deploy chromium yet.

Edit: I am building with the platform=linux/amd64 flag

Edit2: Migrated whole code to fedora:36 running on arm 64 and I am getting same error

START RequestId: 983e9126-a091-460f-9a7b-72b00f29a34f Version: $LATEST
END RequestId: 983e9126-a091-460f-9a7b-72b00f29a34f
REPORT RequestId: 983e9126-a091-460f-9a7b-72b00f29a34f	Duration: 573.49 ms	Billed Duration: 574 ms	Memory Size: 4000 MB	Max Memory Used: 31 MB	
RequestId: 983e9126-a091-460f-9a7b-72b00f29a34f Error: Runtime exited with error: exit status 254
Runtime.ExitError
feita há 2 anos4447 visualizações
7 Respostas
1

In case it helps someone else looking at this... I had an identical issue pop up last week using a node:16 image, which had recently been updated to node:16.15.1. I rolled back to node:16.14.2 to get it working again.

mabuk
respondido há 2 anos
1

For me it happened when the playwright container was updated to 1.23.X, which uses node 16.16.X. Tried to downgrade the Node in the dockerfile after fetching the playwright container, but it didn't help. Since I couldn't identify what breaking change may have caused it, so as temporary solution I pinned the version of playwright docker image my code uses to v1.22.2, and my lambda is working again.

MaxMor
respondido há 2 anos
0
Resposta aceita

After playing around I realised what the issue was. I still do not know what error 254 means but the issue was strictly nodejs 18 lts. Seems like was does not really like it. I was getting error 254 even after building everything for arm (not just x86). After switching to nodes 16 LTS it just worked. Maybe in future nodes 18 will be supported but right now I assume the aws-lambda-ric component does not have the support for it and due to some internal reason the process exits with that error. I am writing this in case anyone else runs in this error in the future. Most likely nodejs 18 might be supported at some point but if you run into this error make sure it is not from using a node version incompatible with was lambda rip yet.

respondido há 2 anos
  • Unfortunately, it appears the problem is not node 18! We have the same problem and the version of node installed is node 16.17.1

0

Your Docker image must be built on the same CPU architecture as the architecture you configure for your Lambda function. Building a Docker image on a Mac with an M1 CPU usually produces an image for the Linux/arm64 architecture, so your Lambda function must be configured for the arm64 architecture as well.

If you're using Docker Desktop on an M1 Mac, you can also produce x86 images using docker buildx build that can be deployed onto Lambda using the x86 architecture. You'll want to pass the --platform=linux/amd64 argument to this command.

By the way, we have successfully tested running Chromium on Lambda on Graviton. If you start with the fedora:36 or fedora:35 base images, you can install prebuilt Chromium RPMs from the Fedora package repository. See, e.g., https://fedora.pkgs.org/36/fedora-aarch64/chromium-99.0.4844.51-1.fc36.aarch64.rpm.html

AWS
ESPECIALISTA
respondido há 2 anos
  • I did compile with he linux/amd64 flag and same result. When I am testing the build locally it does show in Docker Desktop that I am running emu emulation of amd64

  • but I will attempt using the fedora bistro, that is a great tip since we want to migrate to arm anyway

  • Tips Fedora

  • @Michael_F as a later update, I migrated the full code to to fedora:36 and arm64. And I am getting the same error: 254. Is there any documentation for said exit code?

0

Yes you could append the host platform on it. But the issue is a difference between where you build the image and the Architecture setting on the lambda.

Example: if you build the image on an m1 mac push to ECR and set the Architecture setting to x86_64 then you will get this error.

You can either change the setting in lambda or if you are working with multiple people on different systems Id suggest using CodePipeline with a CodeBuild step and you can define the system the pipeline builds on so every-time the build is consistent with a buildspec.yaml like this.

version: 0.2 
 
phases: 
  install: 
    runtime-versions: 
      docker: 18 
  pre_build: 
    commands: 
      - echo Logging in to Amazon ECR... 
      - aws --version 
      - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) 
      - REPOSITORY_URI=$EcrRepo
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_TAG=${COMMIT_HASH:=latest}
  build: 
    commands: 
      - echo Build started on `date` 
      - echo Building the Docker image... 
      - docker build -t $REPOSITORY_URI:latest .
      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:latest
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - aws lambda update-function-code --function-name [YOUR_FUNCTION_NAME] --image-uri $REPOSITORY_URI:$IMAGE_TAG
respondido há 2 anos
  • Solved issue. Was totally unrelated to architecture. After downgrading to node 16 both x86 and arm64 builds worked without a any issues. I was not getting any error for building x86 since I was strictly building for x86 as target architecture. There are still AWS regions that do not support arm but only x86.

  • Keep in mind I was also getting 254 error after migrating everything to arm.

0

Is there any news regarding this? We still have this problem in October. We could not figure out what was going on as there is no log other than error 254. Tried Playwright version 1.27.1 and different docker images, all ubuntu 20.4 and node 16.17.1. Locally they work without issues. We tried putting the container in a k8s pod and it works as well.. It appears there is some sort of problem on the lambda container side, but who knows other than "error 254". We also tried going gradually backwards with playwright version by version, and the only one working is the 1.22.2 as other pointed out

respondido há 2 anos
  • For me this version works: mcr.microsoft.com/playwright:v1.21.0-focal

0

Thanks everyone for all the help - I ran into this issue yesterday. Building the image on my linux machine instead of my m1 macbook pro and then downgrading to the playwright v1.22.2 image both got me past this error. Now, on to fix the next errors!

LynneR
respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas