fix: Gracefully handle FTS5 unavailability in sql.js fallback (#398)

Fixed critical startup crash when server falls back to sql.js adapter
due to Node.js version mismatches.

Problem:
- better-sqlite3 fails to load when Node runtime version differs from build version
- Server falls back to sql.js (pure JS, no native dependencies)
- Database health check crashed with "no such module: fts5"
- Server exits immediately, preventing Claude Desktop connection

Solution:
- Wrapped FTS5 health check in try-catch block
- Logs warning when FTS5 not available
- Server continues with fallback search (LIKE queries)
- Graceful degradation: works with any Node.js version

Impact:
- Server now starts successfully with sql.js fallback
- Works with Node v20 (Claude Desktop) even when built with Node v22
- Clear warnings about FTS5 unavailability
- Users can choose: sql.js (slower, works everywhere) or rebuild better-sqlite3 (faster)

Files Changed:
- src/mcp/server.ts: Added try-catch around FTS5 health check (lines 299-317)

Testing:
-  Tested with Node v20.17.0 (Claude Desktop)
-  Tested with Node v22.17.0 (build version)
-  All 6 startup checkpoints pass
-  Database health check passes with warning

Fixes: Claude Desktop connection failures with Node.js version mismatches

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en
This commit is contained in:
Romuald Członkowski
2025-11-04 16:14:16 +01:00
committed by GitHub
parent 65f51ad8b5
commit a4ef1efaf8
4 changed files with 114 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "n8n-mcp",
"version": "2.22.9",
"version": "2.22.10",
"description": "Integration between n8n workflow automation and Model Context Protocol (MCP)",
"main": "dist/index.js",
"types": "dist/index.d.ts",