Fix node:sqlite V8 crash on invalid UTF-8 in text columns#272
Open
Fix node:sqlite V8 crash on invalid UTF-8 in text columns#272
Conversation
node:sqlite calls v8::String::NewFromUtf8 with kAbort on TEXT columns. Cursor chat blobs often contain truncated multi-byte chars from streaming boundaries, which triggers a V8 CHECK abort (not a JS exception). Select all text-content columns as CAST(col AS BLOB) so node:sqlite returns Uint8Array instead. Decode in JS with TextDecoder fatal:false which replaces bad bytes with U+FFFD. Covers all three SQLite providers (Cursor, Goose, OpenCode). Removes the version blocklist (MIN_NODE_22_PATCH) and lowers engines requirement from >=22.20 to >=22 since the BLOB cast approach works on all Node 22.x versions. Closes #264 Closes #250
87c8c24 to
b45c6f5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CAST(col AS BLOB)in SQL so node:sqlite returnsUint8Arrayinstead of attemptingv8::String::NewFromUtf8(which aborts on invalid UTF-8)TextDecoder('utf-8', { fatal: false })-- bad bytes become U+FFFD instead of crashing the processMIN_NODE_22_PATCH) since this fix works on all Node 22.x versionsblobToText()unit tests covering null, string passthrough, valid UTF-8, invalid bytes, and truncated multi-byte sequencesTest plan
Closes #264