oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.77k stars 2.73k forks source link

Fix lambda layer on x86_64 #5875

Open igoodwinVolly opened 1 year ago

igoodwinVolly commented 1 year ago

What is the type of issue?

Documentation is missing, Documentation is confusing

What is the issue?

I discovered that the AWS Linux 2 custom runtime (for Bun to execute both TS or JS files) lambda function ONLY WORKS if the architecture is arm64.

If the lambda uses the x86_64 architecture, the following error occurs on any and all function invocations:

/opt/bootstrap: line 3: /opt/bun: cannot execute binary file
/opt/bootstrap: line 3: /opt/bun: Success
INIT_REPORT Init Duration: 14.31 ms Phase: init Status: error Error Type: Runtime.ExitError

Please update the documentation for AWS Lambda + Bun to clearly define that the lambda function's architecture MUST be arm64 and the lambda layer MUST support arm64 architectures on Amazon Linux 2 custom runtimes.

Ian

Where did you find it?

  1. Create AWS Lambda function with custom Amazon Linux 2 runtime and x86_64 architecture
  2. Upload or attach Bun v1.0.2 lambda layer (which by default is compatible with both x86_64 and arm64)
  3. Deploy example/lambda.ts file in bun-lambda folder
  4. Enable function URL or click Test
  5. Verify logs display opt/bootstrap errors and function fails to execute
  6. Change function architecture to arm64
  7. Test via function URL or click Test
  8. Verify logs do NOT display error and function invokes properly
Electroid commented 1 year ago

Thanks for reporting, we'll take a look and fix this.

HamzaMateen commented 1 year ago

If it is about documentation fix, please assign me to this issue. I will fix it. Thanks