Files
lancedb/nodejs
Will JonesandClaude Opus 5 3be313f634 test(node): fix flaky optimize cleanup test (#4217)
Backports the test fix from #4183 (commit `21ecafe9a` on `main`) to
`release/v0.39`.

## Root cause

`when optimizing a dataset > cleanups old versions` took its cutoff with
`new Date()`. A JS `Date` has millisecond precision; Lance stores
version
timestamps with nanosecond precision. If the cutoff landed in the same
millisecond as the preceding commit, truncating to milliseconds put the
cutoff
*before* that commit, so the version was not eligible for pruning and
`stats.prune.oldVersionsRemoved` came back as `1` instead of `2`.

This became possible on this branch with #4160, which changed
`cleanupOlderThan`
to be passed to the native binding as an absolute timestamp. It is
timing- and
machine-dependent, which is why it shows up on the fast Linux runners
and not
locally.

## Fix

Wait for the clock to tick over to the next millisecond before capturing
the
cutoff, so the cutoff is strictly later than every commit the test made.
Same
change that is already on `main`.

## Observed failures

-
https://github.com/lancedb/lancedb/actions/runs/34945208311/job/104323950514
— scheduled NPM Publish on `main` at `ffe94a65a`, before #4183 landed.
- https://github.com/lancedb/lancedb/actions/runs/35257750543 — #4216
(`update-lance-12.0.0-v0.39`), which targets this branch and so does not
have the fix.

## Verification

This is a flake, so there is no deterministic local repro to show
red-then-green.
The change is byte-identical to the one merged in #4183; `main` has had
three
green NPM Publish runs since it landed, and no recurrence of this test
on `main`.

Note: `delete unverified`, immediately below, still uses `new Date()`
for its
cutoff. It asserts `toBeGreaterThan(1)` rather than an exact count, so
it has
one version of slack, but it is the same latent race. Left alone here to
keep
this a faithful backport — happy to harden it on `main` and backport
that too.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 15:45:35 -05:00
..
2025-03-21 10:56:29 -07:00
2025-01-29 08:27:07 -08:00

LanceDB JavaScript SDK

A JavaScript library for LanceDB.

Installation

npm install @lancedb/lancedb

This will download the appropriate native library for your platform. We currently support:

  • Linux (x86_64 and aarch64 on glibc and musl)
  • MacOS (Intel and ARM/M1/M2)
  • Windows (x86_64 and aarch64)

Usage

Basic Example

import * as lancedb from "@lancedb/lancedb";
const db = await lancedb.connect("data/sample-lancedb");
const table = await db.createTable("my_table", [
  { id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
  { id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 },
]);
const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
console.log(results);

The quickstart contains more complete examples.

Development

See CONTRIBUTING.md for information on how to contribute to LanceDB.