Prompt
How do I see stack traces from serverless errors?
Latest observation
To see stack traces from Serverless Framework function errors, you usually need to look in the cloud provider logs, because stack traces are often logged there rather than in the deployment output.
On AWS Lambda
1) Check CloudWatch Logs
Go to:
- AWS Console → CloudWatch → Log groups
- Open the log group for your function:
/aws/lambda/<function-name>
You’ll see the error and stack trace in the log stream.
2) Use serverless logs
You can tail logs from the CLI:
serverless logs -f <functionName> -t
To get recent logs:
serverless logs -f <functionName> --tail
If you want a specific time window:
serverless logs -f <functionName> --startTime 1h
3) Make sure your code logs the error
If you catch errors, log them explicitly:
try {
...
} catch (err) {
console.error(err.stack || err);
throw err;
}
If you only do throw new Error(...), Lambda usually includes the stack trace in CloudWatch, but if you swallow the error, it won’t appear.
4) If using API Gateway, return the error properly
If your handler catches the exception and returns a generic response, the stack trace won’t surface. Re-throw the error or log it first.
On other providers
- Azure Functions: check Application Insights / Log Stream
- Google Cloud Functions: check Cloud Logging
- OpenWhisk / other runtimes: use the provider’s function logs
If you mean local Serverless debugging
Run locally with more verbosity:
SLS_DEBUG=* serverless invoke local -f <functionName>
or:
serverless invoke local -f <functionName> --data '{}'
If you’re using Node.js, you can also run with:
NODE_OPTIONS="--trace-uncaught --trace-warnings" serverless invoke local -f <functionName>
Best practice
Make sure your function logs the full error object:
console.error("Function failed:", err);
or:
console.error(err.stack);
If you tell me which provider you’re using, I can give the exact command/path to see the stack trace.