You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Install MCode with the official installer (bundled Node 24.19.0 + better-sqlite3 12.11.1), no other changes.
Run mcode.
Let a session start, or exit the TUI.
This is a native GC/teardown race, so it is intermittent: reproduced once during Starting server..., and it is the same signature that other tools hit on shutdown.
Expected and actual behavior
Expected: the TUI starts and exits normally.
Actual: the process aborts with SIGABRT and prints a native stack trace ending in an assertion inside better-sqlite3's Statement destructor. The session data itself looks fine; the process just dies on teardown.
Alternatively, ship a Node runtime that contains the nodejs/node#65195 fix / #63642 revert. As a data point, several downstream projects fixed the same abort by moving to better-sqlite3 13.x.
Workaround verified locally
Replacing the bundled package in place (13.0.3, N-API prebuilt, no compile step) removes the abort:
cd~/.minimax-code/releases/0.5.5/lib/node_modules/@minimax-ai/code/node_modules
mv better-sqlite3 better-sqlite3.orig
cp -a <better-sqlite3@13.0.3>/node_modules/better-sqlite3 better-sqlite3
After that the TUI starts and exits cleanly (Starting server... -> Ask Mcode -> Intelligence with everyone, bye~) with no assertion, and the APIs mcode uses (prepare/exec/transaction/backup/pragma/function/aggregate/iterate/readonly/fileMustExist/close) all behave the same.
Note: MAVIS_SQLITE3_MODULE_PATH / database.sqlite3ModulePath does not work around this, because chunks/chunk-S2IS2DS4.js does a static import M8 from "better-sqlite3" that always resolves against the package's own node_modules; the bundled copy has to be replaced.
Before submitting
I have searched existing issues.
I have included my version and removed sensitive information.
Product or interface
CLI - interactive TUI
Version
~/.minimax-code/current), installed with the official installer~/.minimax-code/runtime/node-v24.19.0-linux-x64better-sqlite312.11.1 (optionalDependency, compiled locally against the bundled 24.19.0 headers)Platform
Linux
OS version and architecture
Ubuntu 24.04.5 LTS x86_64, kernel 6.8.0-142-lowlatency, glibc 2.39
Issue area
Startup / install / update
Steps to reproduce
mcode.This is a native GC/teardown race, so it is intermittent: reproduced once during
Starting server..., and it is the same signature that other tools hit on shutdown.Expected and actual behavior
Expected: the TUI starts and exits normally.
Actual: the process aborts with
SIGABRTand prints a native stack trace ending in an assertion insidebetter-sqlite3'sStatementdestructor. The session data itself looks fine; the process just dies on teardown.Redacted error summary
Analysis
This is not mcode logic; it is the interaction of the bundled Node 24.19.0 with the
better-sqlite312.x native addon:Node 24.19.0 added cleanup hooks to
node::ObjectWrap(src: add cleanup hooks tonode::ObjectWrapnodejs/node#63642, commit4b5eb7b72d). The header shipped inside the bundled runtime confirms it,include/node/node_object_wrap.h:If a wrapped object survives until the final GC after the environment has been torn down, its destructor calls
RemoveEnvironmentCleanupHook()with a destroyed environment,Environment::GetCurrent()returnsnullptr, and the(env) != nullptrassertion fires. This is Use-after-free inCleanupHookThunkRunfor everynode::ObjectWrapalive at teardown nodejs/node#65195 ("Use-after-free inCleanupHookThunkRunfor everynode::ObjectWrapalive at teardown"); the fix PR src: fix use-after-free in CleanupHookThunkRun nodejs/node#65196 is still open, and Node 24.20.0 / 24.21.0 do not contain a fix.better-sqlite312.11.1 still usesnode::ObjectWrap, which is compiled into the shipped addon. Verified on the installed binary:(
node-pty1.x and othernode::ObjectWrap-based addons are affected by the same Node regression.)Suggested fix
Upgrade
better-sqlite3from12.11.1to 13.x, the first N-API release (node-addon-api), which does not usenode::ObjectWrap:Alternatively, ship a Node runtime that contains the nodejs/node#65195 fix / #63642 revert. As a data point, several downstream projects fixed the same abort by moving to
better-sqlite313.x.Workaround verified locally
Replacing the bundled package in place (13.0.3, N-API prebuilt, no compile step) removes the abort:
After that the TUI starts and exits cleanly (
Starting server...->Ask Mcode->Intelligence with everyone, bye~) with no assertion, and the APIs mcode uses (prepare/exec/transaction/backup/pragma/function/aggregate/iterate/readonly/fileMustExist/close) all behave the same.Note:
MAVIS_SQLITE3_MODULE_PATH/database.sqlite3ModulePathdoes not work around this, becausechunks/chunk-S2IS2DS4.jsdoes a staticimport M8 from "better-sqlite3"that always resolves against the package's ownnode_modules; the bundled copy has to be replaced.Before submitting