Skip to content

TypeScript: Index.fts({ language: "english" }) aborts the Node process with an uncatchable panic #4367

Description

@wjones127

Bug bash: Ready to fix

Bug bash priority: High · critical-fix: yes
From the FTS for Code bug bash (2026-10-01), findings: sdkdocs-1.md. Repros ran against released artifacts (pylance 12.0.0 / 13.0.0b18, lancedb 0.39.0 / 0.40.0b12, @lancedb/lancedb 0.40.0-beta.12) unless stated. $S is the bug bash scratch dir.

  • Category: bug
  • Environment: lancedb TypeScript, local, Node v24.21.0, Linux arm64
  • Artifacts: @lancedb/lancedb 0.40.0-beta.12 (lancedb v0.40.0-beta.12, lance v13.0.0-beta.18)
  • Target tracker: GitHub lancedb/lancedb

Repro

$S/hunt/sdkdocs/ts/lang.mjs:

import * as lancedb from "@lancedb/lancedb";
import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path";
const which = process.argv[2];
try {
  if (which === "index") {
    const db = await lancedb.connect(mkdtempSync(join(tmpdir(), "ldb-")));
    const t = await db.createTable("t", [{ id: 1, code: "getUserName" }]);
    await t.createIndex("code", { config: lancedb.Index.fts({ baseTokenizer: "code", language: process.argv[3] }) });
  } else {
    console.log(await lancedb.tokenize("running", { language: process.argv[3] }));
  }
} catch (e) { console.log("caught", e.name, e.message); }
$ node lang.mjs index Klingon; echo "exit=$?"
thread '<unnamed>' (95409) panicked at nodejs/src/index.rs:242:45:
called `Result::unwrap()` on an `Err` value: Arrow { message: "unknown variant `Klingon`, expected one of `Arabic`, `Danish`, `Dutch`, `English`, `Finnish`, `French`, `German`, `Greek`, `Hungarian`, `Italian`, `Norwegian`, `Portuguese`, `Romanian`, `Russian`, `Spanish`, `Swedish`, `Tamil`, `Turkish` at line 1 column 9", location: Location { file: ".../lance-8ddea23c38163eda/b646eda/rust/lance-index/src/scalar/inverted/tokenizer.rs", line: 839, column: 24 }, backtrace: MaybeBacktrace }
fatal runtime error: failed to initiate panic, error 622329968, aborting
Aborted                    (core dumped) node lang.mjs index
exit=134

$ node lang.mjs index english      # lowercase is also rejected
thread '<unnamed>' (95790) panicked at nodejs/src/index.rs:242:45:

$ node lang.mjs tok Klingon; echo "exit=$?"
caught Error LanceDB does not support the requested language: 'Klingon'
exit=0

The try/catch never runs: the whole process aborts with core dump (exit 134). The same bad value in lancedb.tokenize throws a normal catchable Error.

Expected behavior

Index.fts throws a catchable JS Error, like lancedb.tokenize does in TS and like Python does:

>>> t.create_fts_index('code', language='english')
ValueError LanceDB does not support the requested language: 'english'

Evidence: Python behavior above (lancedb 0.40.0b12); TS tokenize behavior above. FtsOptions.language is typed as plain string (src/lancedb/nodejs/lancedb/indices.ts:530-533), so TS's type checker can't catch a bad value.

Suspected root cause

src/lancedb/nodejs/src/index.rs:241-243 calls opts.language(&language).unwrap(). FtsIndexBuilder::language returns Err for an unknown language (src/lance/rust/lance-index/src/scalar/inverted/tokenizer.rs:839), and the panic crosses the napi boundary and aborts the process. The function already returns napi::Result<Self> (index.rs:233), so the error can be propagated.

Fix direction

Map the error to napi::Error with ? (same message as Python/tokenize), and add a TS test for an invalid language.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcritical-fixBugs that cause crashes, security vulnerabilities, or incorrect data.typescriptTypescript / javascript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions