Summary
After local embeddings became functional on an Intel Mac with opencode-mem@2.22.2, OpenCode consistently crashes during normal /exit. The memory add/search operations succeed; the crash happens later while macOS is finalizing ONNX Runtime's global environment.
The same OpenCode setup did not show this exit crash before enabling opencode-mem local embeddings.
Environment
- macOS 13.3 (22E252), Intel
x86_64
- OpenCode 1.18.9
- Embedded Bun 1.3.14 (
0d9b296a)
- Node.js v22.19.0
- opencode-mem 2.22.2
- onnxruntime-node 1.22.0
- Local model:
Xenova/nomic-embed-text-v1
Steps to reproduce
- Configure
opencode-mem@2.22.2 with the default local embedding model.
- Start OpenCode and invoke
memory add followed by memory search.
- Confirm both operations succeed.
- Exit normally with
/exit.
Actual behavior
The session exits its normal loop and prints the session resume information, then Bun crashes:
panic(main thread): A C++ exception occurred
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
[1] illegal hardware instruction opencode
Bun report from one occurrence:
https://bun.report/1.3.14/ma10d9b296m5nQuhooCw57luDgi2nuD________uhpwVk1w2bkhmylBkz5iI2rowvD2opk4Culqk4Cyq/59C4wn/H_A0eNpzVHDW1lZIrUhOLSjJzM9TyE9OLi0qSk0BAF13CGE
This reproduced three times. The corresponding macOS DiagnosticReports all show the same main-thread teardown stack:
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Termination Reason: Illegal instruction: 4
Crashed Thread: 0, com.apple.main-thread
std::__terminate
std::terminate
onnxruntime::Environment::~Environment()
OrtEnv::Release
OrtApis::ReleaseEnv
std::unique_ptr<Ort::Env>::~unique_ptr
__cxa_finalize_ranges
exit
There is no JS exception immediately before the crash. OpenCode logs show the session loop exiting normally.
Expected behavior
OpenCode should exit normally after using local memory embeddings.
Isolation evidence
Related upstream issues
This appears to be a Bun 1.3.14 + in-process onnxruntime-node teardown failure, with opencode-mem acting as the trigger by loading ONNX into OpenCode's embedded Bun host. A remote/sidecar embedding backend would avoid the native module in the host process, but no remote embedding endpoint is available in this environment.
Summary
After local embeddings became functional on an Intel Mac with
opencode-mem@2.22.2, OpenCode consistently crashes during normal/exit. The memory add/search operations succeed; the crash happens later while macOS is finalizing ONNX Runtime's global environment.The same OpenCode setup did not show this exit crash before enabling
opencode-memlocal embeddings.Environment
x86_640d9b296a)Xenova/nomic-embed-text-v1Steps to reproduce
opencode-mem@2.22.2with the default local embedding model.memory addfollowed bymemory search./exit.Actual behavior
The session exits its normal loop and prints the session resume information, then Bun crashes:
Bun report from one occurrence:
https://bun.report/1.3.14/ma10d9b296m5nQuhooCw57luDgi2nuD________uhpwVk1w2bkhmylBkz5iI2rowvD2opk4Culqk4Cyq/59C4wn/H_A0eNpzVHDW1lZIrUhOLSjJzM9TyE9OLi0qSk0BAF13CGE
This reproduced three times. The corresponding macOS DiagnosticReports all show the same main-thread teardown stack:
There is no JS exception immediately before the crash. OpenCode logs show the session loop exiting normally.
Expected behavior
OpenCode should exit normally after using local memory embeddings.
Isolation evidence
opencode-mem.onnxruntime::Environment::~Environment().sharp/libvips dynamic-library load error, so it did not reach ONNX inference.opencode-memfrom the OpenCode plugin list avoids loading ONNX into the host process.Related upstream issues
process.exit()workaround was already removed)This appears to be a Bun 1.3.14 + in-process
onnxruntime-nodeteardown failure, with opencode-mem acting as the trigger by loading ONNX into OpenCode's embedded Bun host. A remote/sidecar embedding backend would avoid the native module in the host process, but no remote embedding endpoint is available in this environment.