All Products
Search
Document Center

Function Compute:Error handling

Last Updated:Apr 01, 2026

Function Compute catches errors thrown by your Node.js function and returns a structured response. This page covers the two error categories Node.js functions can produce and how to interpret HTTP status codes from the service.

Error types

Captured exceptions

When your function throws an exception, Function Compute catches it and returns a JSON object with three fields:

FieldDescription
errorMessageThe error message string
errorTypeThe JavaScript error class name
stackTraceAn array of stack frames

ECMAScript modules

ECMAScript module syntax requires Node.js 18 or later. The sample code supports one-click deployment (nodejs-fc-err-es).
export const handler = async (event, context) => {
  throw new Error('oops');
};

CommonJS modules

exports.handler = function(event, context, callback) {
  throw new Error('oops');
};

Sample response:

{
    "errorMessage": "oops",
    "errorType": "Error",
    "stackTrace": [
        "Error: oops",
        "    at handler (file:///code/index.mjs:2:9)",
        "    at module.exports (file:///var/fc/runtime/nodejs20/bootstrap.mjs:5655:14)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
    ]
}

Abnormal exits

If your function calls process.exit() while running, the runtime cannot capture a structured error. The service returns a generic message instead:

ECMAScript modules

ECMAScript module syntax requires Node.js 18 or later.
export const handler = async (event, context) => {
  process.exit(1);
};

CommonJS modules

exports.handler = function(event, context, callback) {
  process.exit(1);
};

Sample response:

{
    "errorMessage": "Process exited unexpectedly before completing request (duration: 12ms, maxMemoryUsage: 0MB)"
}

HTTP status codes

Important

A 2xx response does not guarantee the function succeeded. Check for the X-Fc-Error-Type response header to detect function errors returned with a 2xx status code.

When a function invocation fails, Function Compute returns an HTTP status code, a response body, and — for function-level errors — an X-Fc-Error-Type response header. Inspect these signals to handle errors in code or surface them to end users.

Status codeMeaning
2xxFunction Compute received the request. If the response includes the X-Fc-Error-Type header, a function error occurred — for example, an uncaught exception in your code.
4xx (excluding 429)The client that initiated the invocation sent an invalid request.
429The request was throttled.
5xxAn internal error occurred in Function Compute, the function configuration is invalid, or a resource issue exists.

For a full list of invocation errors and resolution steps, see Error handling.