@@ -29,6 +29,21 @@ export function __setLockfileModuleForTests(module) {
2929}
3030export const loadLanceDB = async ( ) => {
3131 if ( ! lancedbImportPromise ) {
32+ // @lancedb /lancedb's napi-rs loader (dist/native.js) detects musl via
33+ // process.report.getReport(). The report's network section performs
34+ // reverse-DNS lookups for every network interface, synchronously on the
35+ // calling thread; on hosts with several interfaces and a slow or flaky
36+ // DNS path (measured on WSL2 + Tailscale) this blocks the event loop for
37+ // 110-250s on the FIRST LanceDB load — the host app's HTTP server and
38+ // pollers freeze with CPU at 0% (main thread stuck in poll()). Excluding
39+ // the network section turns the measured 235s hang into ~3ms and loses
40+ // nothing: isMusl() only reads report.header.glibcVersionRuntime.
41+ try {
42+ process . report . excludeNetwork = true ;
43+ }
44+ catch {
45+ /* Node < 22 without the flag — keep the previous behavior */
46+ }
3247 // Use a createRequire-built require() so LanceDB's CommonJS native bindings
3348 // keep Windows-safe CJS semantics while still working in pure ESM runtimes.
3449 // Do not name this binding "require": bundlers may rewrite bare require()
@@ -50,7 +65,11 @@ function clampInt(value, min, max) {
5065 return min ;
5166 return Math . min ( max , Math . max ( min , Math . floor ( value ) ) ) ;
5267}
68+ const LEGACY_STABLE_MEMORY_ID_REGEX = / ^ [ A - Z a - z 0 - 9 ] [ A - Z a - z 0 - 9 . _ : - ] { 2 , 127 } $ / ;
5369const LEGACY_SECONDS_TIMESTAMP_MAX = 1_000_000_000_000 ;
70+ function isLegacyStableMemoryId ( id ) {
71+ return LEGACY_STABLE_MEMORY_ID_REGEX . test ( id ) ;
72+ }
5473export function normalizeMemoryTimestamp ( value , fallback = Date . now ( ) ) {
5574 const raw = value instanceof Date
5675 ? value . getTime ( )
@@ -1704,20 +1723,19 @@ export class MemoryStore {
17041723 throw new Error ( `Memory ${ id } is outside accessible scopes` ) ;
17051724 }
17061725 return this . runWithFileLock ( ( ) => this . runSerializedUpdate ( async ( ) => {
1707- // Support both full UUID and short prefix (8+ hex chars), same as delete()
1708- // Also support legacy mem-md-N format from older memory-lancedb-pro versions
1726+ // Support full UUID, short hex prefixes, and constrained exact legacy IDs imported
1727+ // from older stores (for example " mem-md-..." or "data-pointer-...").
17091728 const uuidRegex = / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } $ / i;
17101729 const prefixRegex = / ^ [ 0 - 9 a - f ] { 8 , } $ / i;
1711- const legacyRegex = / ^ m e m - m d - \d + $ / i;
17121730 const isFullId = uuidRegex . test ( id ) ;
17131731 const isPrefix = ! isFullId && prefixRegex . test ( id ) ;
1714- const isLegacy = ! isFullId && ! isPrefix && legacyRegex . test ( id ) ;
1715- if ( ! isFullId && ! isPrefix && ! isLegacy ) {
1732+ const isLegacyStableId = ! isFullId && ! isPrefix && isLegacyStableMemoryId ( id ) ;
1733+ if ( ! isFullId && ! isPrefix && ! isLegacyStableId ) {
17161734 throw new Error ( `Invalid memory ID format: ${ id } ` ) ;
17171735 }
17181736 let rows ;
1719- if ( isFullId || isLegacy ) {
1720- // Legacy IDs use exact string match like full UUIDs
1737+ if ( isFullId || isLegacyStableId ) {
1738+ // Legacy IDs use exact string match like full UUIDs.
17211739 const safeId = escapeSqlLiteral ( id ) ;
17221740 rows = await this . table . query ( )
17231741 . where ( `id = '${ safeId } '` )
0 commit comments