dherault / dherault/serverless-offline

free(): invalid next size (fast), Segmentation Faults (SIGSEGV) and other native Node.js crashes

Open
#1,762 6 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
811
Avg merge
2d 4h
Merged PRs (30d)
3

Description

## Bug Report

**Current Behavior**

Serverless offline sporadically crashes with various memory-related errors. The crash is within Node's native code.

**Expected behavior/code**

Serverless offline should not crash.

**Environment**

Both myself (Linux) and my colleague on (Mac M1) have experienced several native crashes in the Node process. We're using the latest version of serverless-offline (13.3.3).

**Possible Solution**

Neither of us have experienced a crash yet running serverless-offline with the `--useInProcess` flag.

**Additional context/Screenshots**

I spent a couple of days trying to figure out if this was some bug in Node.js memory handling or something, because the backtraces from the core dumps just pointed to code within Node. Eventually I tried out this flag on serverless-offline and stability seems to have greatly improved.

I'm creating this bug report for two reasons:

1. I wanted to make this issue so searching for these errors may bring somebody here and let them try to run with `--useInProcess`. It seems to have greatly helped the stability of the project. At first I thought maybe there was something wrong with our Node.js version. We tried upgrading to v20 from v18 (which didn't fix anything), and spent a lot of time searching around for other people having segfaults or memory issues with Node, which was not helpful.
2. To recommend that perhaps a large warning or notice be placed in the docs to indicate that running in the default mode with worker threads may cause instability issues. I'm not sure which native extensions in our project are to blame, but it was remarkably hard to track down exactly what was happening when every now and again our servers would just crash seemingly at random.

I'm not sure if I expect anything to change within serverless-offline, but it would have been really helpful to have an issue like this to look into to help figure out why our servers were crashing.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the native crash in serverless-offline 13.3.3, comparing the default worker-thread mode with the documented --useInProcess flag on the reported environments. Review the existing documentation for the flag and determine whether the issue can be narrowed to a reproducible cause or a clear stability warning; done means a verified fix or an agreed documentation change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, devtools
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.