Skip to content

fix(build): pin Node 24.18.0 to stop the agent crash loop - #214

Merged
diegosucaria merged 1 commit into
masterfrom
fix/node-pin-agent-crash
Sep 10, 2026
Merged

diegosucaria merged 1 commit into
masterfrom
fix/node-pin-agent-crash

Conversation

@diegosucaria

Copy link
Copy Markdown
Owner

Summary

Since the 2026-09-07 release, the agent crashes whenever a scheduled job starts. The morning briefing, the backups and the other daily jobs have not run since.

Cause

The Dockerfiles used the moving node:24-alpine tag. The Sept 7 rebuild pulled Node 24.20. Node 24.19 added cleanup hooks to node::ObjectWrap (nodejs/node#65446, still open). better-sqlite3 builds its classes on ObjectWrap. When garbage collection frees one of those objects, Node fails RemoveEnvironmentCleanupHook ... Assertion failed: (env) != nullptr and aborts. Job start is a busy moment, so that is when it happens.

Changes

  • Pin node:24.18.0-alpine, the version in the last good build, in all five Dockerfiles. Each carries a note on when it is safe to move. CI and .nvmrc now use 24.18.0 too (they were on 20 and 18).
  • searchMessages: the pattern was % q % , which only matched text ending in a space. searchMemory and searchHistory never returned chat history. It now uses %q% and escapes LIKE wildcards.
  • sendMessage: keep an explicit @lid target. It rebuilt every target as <digits>@s.whatsapp.net, which reaches nobody when a contact is only known by LID.

I tried npm ci in the builders, but it rejects turbo's pruned lockfile for the agent, so they stay on npm install.

Tests

  • New AgentDB.searchMessages tests run against a real SQLite database. The old tests mocked this method, so the bug never surfaced.
  • New sendMessage tests cover a @lid target and a bare phone number.

Since the 2026-09-07 release the agent aborts whenever a scheduled job
starts, so the morning briefing and every other daily job stopped.

Cause: the Dockerfiles used the floating node:24-alpine tag. The rebuild
pulled Node 24.20, and Node 24.19 added cleanup hooks to node::ObjectWrap
(nodejs/node#65446). better-sqlite3 builds on ObjectWrap, so when garbage
collection frees one of its objects Node fails
"RemoveEnvironmentCleanupHook ... (env) != nullptr" and aborts.

- Pin node:24.18.0-alpine (the last good build) in all five Dockerfiles,
  with a note on when to move it. Match CI and .nvmrc.
- searchMessages: the LIKE pattern was "% q % ", which only matched text
  ending in a space, so searchMemory/searchHistory never found chat
  history. Use "%q%" and escape LIKE wildcards.
- sendMessage: keep an explicit "@lid" target. It rebuilt every target
  as "<digits>@s.whatsapp.net", which reaches nobody for LID-only contacts.
@diegosucaria
diegosucaria merged commit 8b603e5 into master Sep 10, 2026
2 checks passed
@diegosucaria
diegosucaria deleted the fix/node-pin-agent-crash branch September 10, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant