Skip to content
Latchkey

AWS Lambda "Runtime.ExitError ... exited before completing request" in CI

The Lambda process crashed or called process.exit() during the invocation, so the runtime never received a response. The runtime reports Runtime.ExitError and that the process exited before completing the request.

What this error means

An invoke fails with "RequestId: ... Error: Runtime exited with error: exit status 1" or "exited before completing the request (unexpected)". There is often no application stack trace, just the exit.

lambda
RequestId: 7f8e9d0a Error: Runtime exited without providing a reason
Runtime.ExitError

Common causes

The handler calls process.exit()

Code (or a library) calls process.exit(), killing the runtime before it returns a response.

An unhandled crash in native or async code

A segfault in a native addon, or an uncaught exception in a callback outside the promise chain, terminates the process abruptly.

How to fix it

Remove explicit process exits

  1. Grep the handler and its dependencies for process.exit.
  2. Return or resolve from the handler instead of exiting the process.
  3. Let the runtime manage the process lifecycle.
Terminal
grep -rn "process.exit" src/

Surface the real crash

Add a top-level handler for uncaught errors so the cause is logged before the process dies.

handler.mjs
process.on('unhandledRejection', (e) => { console.error(e); });

How to prevent it

  • Never call process.exit() inside a Lambda handler.
  • Handle promise rejections and callback errors explicitly.
  • Pin native addon versions that match the Lambda runtime.

Frequently asked questions

What causes ""exited before completing the request""?
Code (or a library) calls process.exit(), killing the runtime before it returns a response.
How do I fix "exited before completing the request"?
Remove explicit process exits

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card