gitnexus 1.6.4-rc.75 → 1.6.4-rc.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,10 +17,10 @@ export function populateGoRangeBindings(parsedFiles, _indexes, ctx) {
|
|
|
17
17
|
const scopeMap = new Map(parsed.scopes.map((s) => [s.id, s]));
|
|
18
18
|
for (const rangeNode of tree.rootNode.descendantsOfType('for_statement')) {
|
|
19
19
|
const rangeClause = rangeNode.namedChildren.find((c) => c.type === 'range_clause');
|
|
20
|
-
if (rangeClause ===
|
|
20
|
+
if (rangeClause === undefined)
|
|
21
21
|
continue;
|
|
22
22
|
const left = rangeClause.namedChildren.find((c) => c.type === 'expression_list');
|
|
23
|
-
if (left ===
|
|
23
|
+
if (left === undefined)
|
|
24
24
|
continue;
|
|
25
25
|
const rangeExpr = rangeClause.namedChildren.find((c, idx) => c.type !== 'expression_list' && idx > rangeClause.namedChildren.indexOf(left));
|
|
26
26
|
if (rangeExpr === undefined)
|
|
@@ -38,7 +38,7 @@ export function synthesizeGoTypeBindings(rootNode) {
|
|
|
38
38
|
const args = expr.childForFieldName('arguments');
|
|
39
39
|
if (fn?.type === 'identifier' && fn.text === 'new' && args !== null) {
|
|
40
40
|
const typeArg = args.namedChildren.find((c) => ['type_identifier', 'qualified_type'].includes(c.type));
|
|
41
|
-
if (typeArg !==
|
|
41
|
+
if (typeArg !== undefined) {
|
|
42
42
|
const typeName = extractSimpleTypeNameText(typeArg);
|
|
43
43
|
const nameNodes = lhs.namedChildren.filter((c) => c.type === 'identifier');
|
|
44
44
|
if (nameNodes.length > 0) {
|
|
@@ -54,11 +54,11 @@ export function synthesizeGoTypeBindings(rootNode) {
|
|
|
54
54
|
const sliceOrMap = args.namedChildren.find((c) =>
|
|
55
55
|
// V1: channel_type not handled — make(chan T) produces no typeBinding.
|
|
56
56
|
['slice_type', 'map_type'].includes(c.type));
|
|
57
|
-
if (sliceOrMap !==
|
|
57
|
+
if (sliceOrMap !== undefined) {
|
|
58
58
|
let typeName = '';
|
|
59
59
|
if (sliceOrMap.type === 'slice_type') {
|
|
60
60
|
const elem = sliceOrMap.namedChildren.find((c) => ['type_identifier', 'qualified_type'].includes(c.type));
|
|
61
|
-
if (elem !==
|
|
61
|
+
if (elem !== undefined)
|
|
62
62
|
typeName = extractSimpleTypeNameText(elem);
|
|
63
63
|
}
|
|
64
64
|
else if (sliceOrMap.type === 'map_type') {
|
|
@@ -119,6 +119,31 @@ export declare const loadCachedEmbeddings: () => Promise<{
|
|
|
119
119
|
* @param execQuery - Cypher query executor (typically pool-adapter's `executeQuery`)
|
|
120
120
|
*/
|
|
121
121
|
export declare const fetchExistingEmbeddingHashes: (execQuery: (cypher: string) => Promise<any[]>) => Promise<Map<string, string> | undefined>;
|
|
122
|
+
/**
|
|
123
|
+
* Flush the WAL so all pending writes are visible to subsequent readers.
|
|
124
|
+
*
|
|
125
|
+
* Best-effort: swallows errors from older LadybugDB versions or schemaless
|
|
126
|
+
* databases that do not support the CHECKPOINT command. A no-op when there
|
|
127
|
+
* is nothing pending, so safe (and cheap) to call unconditionally after any
|
|
128
|
+
* write path.
|
|
129
|
+
*
|
|
130
|
+
* Use this instead of safeClose when the connection must stay open
|
|
131
|
+
* (e.g. the /api/embed handler that keeps serving queries after flushing).
|
|
132
|
+
*
|
|
133
|
+
* @see safeClose — CHECKPOINT + connection/database close
|
|
134
|
+
*/
|
|
135
|
+
export declare const flushWAL: () => Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Flush the WAL and close the connection and database handles.
|
|
138
|
+
*
|
|
139
|
+
* Consolidates the CHECKPOINT + close pattern into a single function so
|
|
140
|
+
* callers never call conn.close() or db.close() directly (#1376).
|
|
141
|
+
* An ESLint no-restricted-syntax rule enforces this — see eslint.config.mjs.
|
|
142
|
+
*
|
|
143
|
+
* @see flushWAL — CHECKPOINT-only (connection stays open)
|
|
144
|
+
* @see closeLbug — safeClose + module state reset (full teardown)
|
|
145
|
+
*/
|
|
146
|
+
export declare const safeClose: () => Promise<void>;
|
|
122
147
|
export declare const closeLbug: () => Promise<void>;
|
|
123
148
|
export declare const isLbugReady: () => boolean;
|
|
124
149
|
/**
|
|
@@ -206,31 +206,7 @@ export const withLbugDb = async (dbPath, operation) => {
|
|
|
206
206
|
// Close stale connection inside the session lock to prevent race conditions
|
|
207
207
|
// with concurrent operations that might acquire the lock between cleanup steps
|
|
208
208
|
await runWithSessionLock(async () => {
|
|
209
|
-
|
|
210
|
-
if (conn) {
|
|
211
|
-
try {
|
|
212
|
-
await conn.query('CHECKPOINT');
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
/* best-effort */
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
try {
|
|
219
|
-
if (conn)
|
|
220
|
-
await conn.close();
|
|
221
|
-
}
|
|
222
|
-
catch {
|
|
223
|
-
/* best-effort */
|
|
224
|
-
}
|
|
225
|
-
try {
|
|
226
|
-
if (db)
|
|
227
|
-
await db.close();
|
|
228
|
-
}
|
|
229
|
-
catch {
|
|
230
|
-
/* best-effort */
|
|
231
|
-
}
|
|
232
|
-
conn = null;
|
|
233
|
-
db = null;
|
|
209
|
+
await safeClose();
|
|
234
210
|
currentDbPath = null;
|
|
235
211
|
ftsLoaded = false;
|
|
236
212
|
vectorExtensionLoaded = false;
|
|
@@ -254,27 +230,7 @@ const ensureLbugInitialized = async (dbPath) => {
|
|
|
254
230
|
const doInitLbug = async (dbPath) => {
|
|
255
231
|
// Different database requested — close the old one first
|
|
256
232
|
if (conn || db) {
|
|
257
|
-
|
|
258
|
-
if (conn) {
|
|
259
|
-
try {
|
|
260
|
-
await conn.query('CHECKPOINT');
|
|
261
|
-
}
|
|
262
|
-
catch {
|
|
263
|
-
/* ignore — older LadybugDB or schemaless DB may not accept it */
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
if (conn)
|
|
268
|
-
await conn.close();
|
|
269
|
-
}
|
|
270
|
-
catch { }
|
|
271
|
-
try {
|
|
272
|
-
if (db)
|
|
273
|
-
await db.close();
|
|
274
|
-
}
|
|
275
|
-
catch { }
|
|
276
|
-
conn = null;
|
|
277
|
-
db = null;
|
|
233
|
+
await safeClose();
|
|
278
234
|
currentDbPath = null;
|
|
279
235
|
ftsLoaded = false;
|
|
280
236
|
vectorExtensionLoaded = false;
|
|
@@ -948,37 +904,64 @@ export const fetchExistingEmbeddingHashes = async (execQuery) => {
|
|
|
948
904
|
throw err;
|
|
949
905
|
}
|
|
950
906
|
};
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Flush the WAL so all pending writes are visible to subsequent readers.
|
|
909
|
+
*
|
|
910
|
+
* Best-effort: swallows errors from older LadybugDB versions or schemaless
|
|
911
|
+
* databases that do not support the CHECKPOINT command. A no-op when there
|
|
912
|
+
* is nothing pending, so safe (and cheap) to call unconditionally after any
|
|
913
|
+
* write path.
|
|
914
|
+
*
|
|
915
|
+
* Use this instead of safeClose when the connection must stay open
|
|
916
|
+
* (e.g. the /api/embed handler that keeps serving queries after flushing).
|
|
917
|
+
*
|
|
918
|
+
* @see safeClose — CHECKPOINT + connection/database close
|
|
919
|
+
*/
|
|
920
|
+
export const flushWAL = async () => {
|
|
921
|
+
if (!conn)
|
|
922
|
+
return;
|
|
923
|
+
try {
|
|
924
|
+
await conn.query('CHECKPOINT');
|
|
967
925
|
}
|
|
926
|
+
catch {
|
|
927
|
+
/* ignore — older LadybugDB or schemaless DB may not accept it */
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
/**
|
|
931
|
+
* Flush the WAL and close the connection and database handles.
|
|
932
|
+
*
|
|
933
|
+
* Consolidates the CHECKPOINT + close pattern into a single function so
|
|
934
|
+
* callers never call conn.close() or db.close() directly (#1376).
|
|
935
|
+
* An ESLint no-restricted-syntax rule enforces this — see eslint.config.mjs.
|
|
936
|
+
*
|
|
937
|
+
* @see flushWAL — CHECKPOINT-only (connection stays open)
|
|
938
|
+
* @see closeLbug — safeClose + module state reset (full teardown)
|
|
939
|
+
*/
|
|
940
|
+
export const safeClose = async () => {
|
|
941
|
+
await flushWAL();
|
|
968
942
|
if (conn) {
|
|
969
943
|
try {
|
|
944
|
+
// eslint-disable-next-line no-restricted-syntax -- sole authorised close site
|
|
970
945
|
await conn.close();
|
|
971
946
|
}
|
|
972
|
-
catch {
|
|
947
|
+
catch {
|
|
948
|
+
/* best-effort */
|
|
949
|
+
}
|
|
973
950
|
conn = null;
|
|
974
951
|
}
|
|
975
952
|
if (db) {
|
|
976
953
|
try {
|
|
954
|
+
// eslint-disable-next-line no-restricted-syntax -- sole authorised close site
|
|
977
955
|
await db.close();
|
|
978
956
|
}
|
|
979
|
-
catch {
|
|
957
|
+
catch {
|
|
958
|
+
/* best-effort */
|
|
959
|
+
}
|
|
980
960
|
db = null;
|
|
981
961
|
}
|
|
962
|
+
};
|
|
963
|
+
export const closeLbug = async () => {
|
|
964
|
+
await safeClose();
|
|
982
965
|
currentDbPath = null;
|
|
983
966
|
ftsLoaded = false;
|
|
984
967
|
vectorExtensionLoaded = false;
|
package/dist/server/api.js
CHANGED
|
@@ -13,7 +13,7 @@ import path from 'path';
|
|
|
13
13
|
import fs from 'fs/promises';
|
|
14
14
|
import { createRequire } from 'node:module';
|
|
15
15
|
import { loadMeta, listRegisteredRepos, getStoragePath } from '../storage/repo-manager.js';
|
|
16
|
-
import { executeQuery, executePrepared, executeWithReusedStatement, streamQuery, closeLbug, withLbugDb, } from '../core/lbug/lbug-adapter.js';
|
|
16
|
+
import { executeQuery, executePrepared, executeWithReusedStatement, streamQuery, flushWAL, closeLbug, withLbugDb, } from '../core/lbug/lbug-adapter.js';
|
|
17
17
|
import { isWriteQuery } from '../core/lbug/pool-adapter.js';
|
|
18
18
|
import { NODE_TABLES } from '../_shared/index.js';
|
|
19
19
|
import { searchFTSFromLbug } from '../core/search/bm25-index.js';
|
|
@@ -1508,13 +1508,8 @@ export const createServer = async (port, host = '127.0.0.1') => {
|
|
|
1508
1508
|
// Flush WAL so subsequent /api/search requests see the new
|
|
1509
1509
|
// embeddings immediately (#1149). In the CLI path closeLbug()
|
|
1510
1510
|
// handles this during process exit, but the server keeps the
|
|
1511
|
-
// connection open for other routes
|
|
1512
|
-
|
|
1513
|
-
await executeQuery('CHECKPOINT');
|
|
1514
|
-
}
|
|
1515
|
-
catch {
|
|
1516
|
-
/* best-effort -- older LadybugDB may not support it */
|
|
1517
|
-
}
|
|
1511
|
+
// connection open for other routes — a CHECKPOINT is enough.
|
|
1512
|
+
await flushWAL();
|
|
1518
1513
|
});
|
|
1519
1514
|
clearTimeout(embedTimeout);
|
|
1520
1515
|
releaseRepoLock(repoLockPath);
|
package/package.json
CHANGED