@delali/narsil 0.4.1-next.215 → 0.4.2-next.271
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.
- package/README.md +1 -1
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +9 -3
- package/dist/adapters/gcs.d.ts +1 -1
- package/dist/adapters/indexeddb.d.ts +6 -1
- package/dist/adapters/indexeddb.mjs +20 -26
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/adapters/s3.d.ts +1 -1
- package/dist/{adapters-pljAqmrC.d.ts → adapters-8LcdNB77.d.ts} +18 -1
- package/dist/browser/{chunk-GBJSEHVJ.mjs → chunk-DPRCAVC2.mjs} +14 -8
- package/dist/browser/{chunk-YINZFPLT.mjs → chunk-WRRXR57N.mjs} +1 -1
- package/dist/browser/{chunk-QAOVAYAG.mjs → chunk-XBWABEL3.mjs} +1 -1
- package/dist/browser/{chunk-4E5APHTM.mjs → chunk-Y5CSZDOH.mjs} +1 -1
- package/dist/browser/{durability-config-75NSFCQN.mjs → durability-config-UP3OTUMB.mjs} +34 -2
- package/dist/browser/{msgpack-leaf-44XNWSSY.mjs → msgpack-leaf-FEPCLXXY.mjs} +7 -1
- package/dist/browser/{optional-reads-6LN3HMUH.mjs → optional-reads-NQO5DKM4.mjs} +18 -16
- package/dist/browser/{optional-writes-76DWMRQH.mjs → optional-writes-HVPPDHSY.mjs} +259 -104
- package/dist/browser/{storage-leaf-5UTR5K7J.mjs → storage-leaf-42IZEOJJ.mjs} +1473 -305
- package/dist/{capabilities-BOFFMx84.d.ts → capabilities-BoWiLNv7.d.ts} +76 -61
- package/dist/{chunk-DBC4EJWB.mjs → chunk-33ZMFOAR.mjs} +1 -1
- package/dist/{chunk-NCIGNQJE.mjs → chunk-4GCHJ3XD.mjs} +930 -387
- package/dist/{chunk-7P5YWDRQ.mjs → chunk-4WQNWAQE.mjs} +1 -1
- package/dist/{chunk-357KIU5E.mjs → chunk-5E3TJ4P3.mjs} +5 -5
- package/dist/{chunk-GXCDWLQI.mjs → chunk-5GYGHPCH.mjs} +7 -1
- package/dist/{chunk-SMQPZHPS.mjs → chunk-ATQ6JR3I.mjs} +1 -1
- package/dist/{chunk-2K24MEYV.mjs → chunk-BBIAUHAB.mjs} +3 -3
- package/dist/{react-native/chunks/chunk-MMPBO4WR.mjs → chunk-DA32WXBT.mjs} +2 -2
- package/dist/{chunk-MSJD74GN.mjs → chunk-EALKCTWH.mjs} +5 -5
- package/dist/{chunk-755NM4PL.mjs → chunk-FOGTBAYN.mjs} +183 -21
- package/dist/{chunk-6GHX35ZM.mjs → chunk-GTBJSNN2.mjs} +1 -1
- package/dist/{chunk-DDUXEJXW.mjs → chunk-H6LWGMPQ.mjs} +45 -22
- package/dist/{chunk-UNEEFTEU.mjs → chunk-HZ3OAUTL.mjs} +2 -1
- package/dist/{chunk-M3B7SGJB.mjs → chunk-KL4ORYJW.mjs} +6 -6
- package/dist/{chunk-IL5DRCNU.mjs → chunk-KQWTS7AM.mjs} +1 -1
- package/dist/{chunk-DKIMHIBC.mjs → chunk-KX3OP6VP.mjs} +2 -2
- package/dist/{chunk-D456ZFPQ.mjs → chunk-MIIJ5O3O.mjs} +2 -2
- package/dist/{chunk-PP3W5PQQ.mjs → chunk-MS746XNY.mjs} +285 -118
- package/dist/{chunk-WM5KJSQV.mjs → chunk-NFA3WHJU.mjs} +1 -1
- package/dist/{react-native/chunks/chunk-ZUJCUPVS.mjs → chunk-OETLM4EH.mjs} +1 -1
- package/dist/{chunk-MYN4K5IS.mjs → chunk-OLXFIUIZ.mjs} +1 -1
- package/dist/{chunk-P4F4UWLC.mjs → chunk-PSO7V7VW.mjs} +17 -3
- package/dist/{chunk-X3EQCQLP.mjs → chunk-Q4NLL66U.mjs} +2 -2
- package/dist/{chunk-WC5KAWXQ.mjs → chunk-QJFKL4NK.mjs} +4 -4
- package/dist/{chunk-MSIN4NM3.mjs → chunk-S3JHYPH7.mjs} +6 -1
- package/dist/{chunk-3IE3A74H.mjs → chunk-SSITKQU6.mjs} +3 -3
- package/dist/{chunk-B3MO37YF.mjs → chunk-TANKI7TG.mjs} +1 -1
- package/dist/{chunk-Z7XSHKOF.mjs → chunk-TI4G3SIG.mjs} +63 -144
- package/dist/{chunk-OGYSPNL2.mjs → chunk-TT3UDDL3.mjs} +7 -7
- package/dist/{react-native/chunks/chunk-4FUCRLSA.mjs → chunk-VHIOGDVD.mjs} +1 -1
- package/dist/{chunk-AXDB6KUQ.mjs → chunk-W3JH2IK6.mjs} +4 -4
- package/dist/{chunk-CERPUGRK.mjs → chunk-WIT6B5OB.mjs} +2 -2
- package/dist/{chunk-MI6UZGUR.mjs → chunk-XGVSG6ZU.mjs} +3 -3
- package/dist/{chunk-6I6OO6B2.mjs → chunk-XWPNRHTG.mjs} +4 -4
- package/dist/{chunk-WTMCGZ74.mjs → chunk-YHZSSPG3.mjs} +2 -2
- package/dist/chunk-ZYEEOZTT.mjs +52 -0
- package/dist/{client-BhNxHtcZ.d.ts → client-B0NPZSKY.d.ts} +4 -4
- package/dist/client.d.ts +9 -9
- package/dist/client.mjs +2 -2
- package/dist/{config-P9zW3Zz7.d.ts → config-B3-sw887.d.ts} +3 -3
- package/dist/{config-BJSL7piq.d.ts → config-DL_nkguq.d.ts} +4 -4
- package/dist/{direct-executor-GWJXDFLD.mjs → direct-executor-PCBB6FCO.mjs} +4 -4
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +33 -3
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/transport/grpc.mjs +4 -4
- package/dist/distribution/transport/in-memory.mjs +1 -1
- package/dist/distribution/transport/tcp.mjs +12 -7
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +167 -91
- package/dist/{durability-config-VWS2K24E.mjs → durability-config-HWKWP35M.mjs} +34 -2
- package/dist/embeddings/openai.d.ts +7 -3
- package/dist/embeddings/openai.mjs +37 -31
- package/dist/{engine-DoFnkRoF.d.ts → engine-DGG_yX0p.d.ts} +3 -3
- package/dist/{index-B_vmxpgW.d.ts → index-fX_FbuRT.d.ts} +1 -1
- package/dist/index.browser.mjs +3 -3
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +4 -4
- package/dist/index.react-native.mjs +4 -4
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/{long-query-thread-GNTDYDOZ.mjs → long-query-thread-4ALYIIC4.mjs} +14 -14
- package/dist/msgpack-leaf-6ZBZWFRD.mjs +9 -0
- package/dist/{optional-reads-UCS23AWP.mjs → optional-reads-ESDVS225.mjs} +18 -16
- package/dist/{optional-writes-2AHJCGTY.mjs → optional-writes-2OK4TOLY.mjs} +9 -8
- package/dist/{paged-partition-archive-GBAHDT55.mjs → paged-partition-archive-Y5OAKNRB.mjs} +13 -13
- package/dist/partial-words.browser.mjs +3 -3
- package/dist/partial-words.mjs +4 -4
- package/dist/pattern.browser.mjs +2 -2
- package/dist/pattern.mjs +2 -2
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +14 -14
- package/dist/{query-actions-IDCUA7UV.mjs → query-actions-UQVQZFIJ.mjs} +4 -4
- package/dist/query-suggestions/merge-worker.mjs +7 -7
- package/dist/query-suggestions.browser.mjs +3 -3
- package/dist/query-suggestions.d.ts +3 -3
- package/dist/query-suggestions.mjs +5 -5
- package/dist/{chunk-F26DOOUH.mjs → react-native/chunks/chunk-4OOUY2K7.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-LPX26NNL.mjs → chunk-5MYHYBET.mjs} +286 -118
- package/dist/react-native/chunks/{chunk-MRH36RN3.mjs → chunk-AVCMTWET.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-HTBY4GON.mjs → chunk-GS6LGXY3.mjs} +1 -1
- package/dist/{chunk-UHLFCGZ3.mjs → react-native/chunks/chunk-LE4DTMDL.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-TG56N5JC.mjs → chunk-VIO5IPF7.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-UO44MA5M.mjs → chunk-VRI5XH2M.mjs} +7 -1
- package/dist/{chunk-R2PJKSNL.mjs → react-native/chunks/chunk-XGS2UYVI.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-AJAH6X7W.mjs → chunk-XW6GZQWP.mjs} +4 -4
- package/dist/react-native/chunks/{chunk-SCGBU47K.mjs → chunk-Z44S6WW5.mjs} +2 -2
- package/dist/react-native/chunks/{durability-config-FCSD4MXY.mjs → durability-config-HJETGZVB.mjs} +34 -2
- package/dist/react-native/chunks/msgpack-leaf-4MIGXWZT.mjs +7 -0
- package/dist/react-native/chunks/{optional-reads-4XCJ34QG.mjs → optional-reads-TN3PT6M4.mjs} +18 -16
- package/dist/react-native/chunks/{optional-writes-XYZVTBFB.mjs → optional-writes-LZDHB7FX.mjs} +8 -7
- package/dist/react-native/chunks/{restore-queue-NOKQZJ2Z.mjs → restore-queue-J7SB263E.mjs} +7 -7
- package/dist/react-native/chunks/{segment-codec-leaf-3ZXBJVKH.mjs → segment-codec-leaf-PEKX7TBL.mjs} +5 -5
- package/dist/react-native/chunks/{segment-merge-leaf-3Z7MMPWE.mjs → segment-merge-leaf-I2EC7H6R.mjs} +6 -6
- package/dist/react-native/chunks/{storage-leaf-KJOX3MMW.mjs → storage-leaf-RQXM7HBO.mjs} +1481 -314
- package/dist/react-native/chunks/{store-leaf-QGLVSO5X.mjs → store-leaf-EZGCLSLM.mjs} +6 -6
- package/dist/react-native/chunks/{suggestions-leaf-6GI5ZSW6.mjs → suggestions-leaf-JNGH2JYC.mjs} +6 -6
- package/dist/react-native/chunks/{worker-copies-ALOD7TSP.mjs → worker-copies-2OWLLBCV.mjs} +5 -5
- package/dist/react-native/partial-words.mjs +4 -4
- package/dist/react-native/pattern.mjs +2 -2
- package/dist/react-native/query-suggestions.mjs +4 -4
- package/dist/react-native/sync.mjs +4 -4
- package/dist/react-native/synonyms.mjs +4 -4
- package/dist/react.d.ts +10 -10
- package/dist/react.mjs +0 -2
- package/dist/{rerank-HB6DU6GS.mjs → rerank-TQ4SU76L.mjs} +4 -4
- package/dist/rerankers/http.d.ts +1 -1
- package/dist/rerankers/http.mjs +19 -15
- package/dist/{restore-queue-VUQHGCXE.mjs → restore-queue-W7U2X6V3.mjs} +7 -7
- package/dist/{schema-CzG9OUw5.d.ts → schema-CFnQ-WI3.d.ts} +1 -1
- package/dist/{segment-codec-leaf-TW2FPAAT.mjs → segment-codec-leaf-WGP4FBXF.mjs} +5 -5
- package/dist/{segment-merge-leaf-BS3QV5PZ.mjs → segment-merge-leaf-FYWJQSPL.mjs} +5 -5
- package/dist/server.d.ts +86 -12
- package/dist/server.mjs +2243 -1918
- package/dist/{storage-leaf-5IG2HPNY.mjs → storage-leaf-GRG44RQA.mjs} +1193 -219
- package/dist/{store-leaf-ZWSOK2DV.mjs → store-leaf-YDJVH73G.mjs} +6 -6
- package/dist/{suggestions-leaf-MUZNKQVF.mjs → suggestions-leaf-5UFJV7SC.mjs} +8 -8
- package/dist/sync/filesystem.d.ts +4 -4
- package/dist/sync/filesystem.mjs +12 -12
- package/dist/sync/indexeddb.browser.mjs +1 -1
- package/dist/sync/indexeddb.d.ts +4 -4
- package/dist/sync/indexeddb.mjs +2 -2
- package/dist/sync.browser.mjs +4 -4
- package/dist/sync.d.ts +5 -5
- package/dist/sync.mjs +4 -4
- package/dist/synonyms.browser.mjs +3 -3
- package/dist/synonyms.mjs +4 -4
- package/dist/{tasks-DrLiolTG.d.ts → tasks-B2MDjPL0.d.ts} +4 -4
- package/dist/{thread-6ZBCENAP.mjs → thread-6YLVL2NC.mjs} +13 -13
- package/dist/{types-pS-mAJmX.d.ts → types-DGjk684l.d.ts} +2 -2
- package/dist/vector/search-worker.d.ts +2 -2
- package/dist/{worker-copies-32HWFUH7.mjs → worker-copies-IP4L7KEW.mjs} +7 -7
- package/dist/workers/entry.mjs +16 -16
- package/package.json +12 -10
- package/dist/chunk-HLPRHOSO.mjs +0 -17
- package/dist/msgpack-leaf-H5ZYW7S7.mjs +0 -9
- package/dist/react-native/chunks/msgpack-leaf-JMNGSTRW.mjs +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readRecentMemoryFigures, readMemoryFigures } from './chunk-
|
|
1
|
+
import { readRecentMemoryFigures, readMemoryFigures } from './chunk-MS746XNY.mjs';
|
|
2
2
|
import { collectGarbageBeforeAnswerRefusal, collectYoungGenerationBeforeRefusal, reservedHeapBytes, admitHeapBytes } from './chunk-2AFZE7Y3.mjs';
|
|
3
3
|
import { NarsilError, ErrorCodes, ServerErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { withOpenIndex, oneAtATime, validateBM25Params, storedBM25Params, emitSyncChange } from './chunk-
|
|
1
|
+
import { withOpenIndex, oneAtATime, validateBM25Params, storedBM25Params, emitSyncChange } from './chunk-MS746XNY.mjs';
|
|
2
2
|
import { ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
3
3
|
|
|
4
4
|
// src/engine/bm25-update.ts
|
|
@@ -5,6 +5,7 @@ var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
|
5
5
|
var MAX_BACKOFF_MS = 3e4;
|
|
6
6
|
var BASE_BACKOFF_MS = 1e3;
|
|
7
7
|
var MAX_JITTER_MS = 1e3;
|
|
8
|
+
var TIMER_DELAY_LIMIT_MS = 2147483647;
|
|
8
9
|
|
|
9
10
|
// src/http-retry/index.ts
|
|
10
11
|
function computeBackoffMs(attempt, retryAfterSeconds) {
|
|
@@ -30,9 +31,22 @@ async function resolveApiKey(apiKey, service, invalidCode) {
|
|
|
30
31
|
return resolved;
|
|
31
32
|
}
|
|
32
33
|
function buildSignal(callerSignal, timeoutMs) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
const deadline = performance.now() + timeoutMs;
|
|
36
|
+
const signal = callerSignal === void 0 ? controller.signal : AbortSignal.any([callerSignal, controller.signal]);
|
|
37
|
+
let timer;
|
|
38
|
+
const check = () => {
|
|
39
|
+
if (signal.aborted) return;
|
|
40
|
+
const remaining = deadline - performance.now();
|
|
41
|
+
if (remaining <= 0) {
|
|
42
|
+
controller.abort(new DOMException("The operation timed out", "TimeoutError"));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
timer = setTimeout(check, Math.min(remaining, TIMER_DELAY_LIMIT_MS));
|
|
46
|
+
if (typeof timer === "object") timer.unref();
|
|
47
|
+
};
|
|
48
|
+
check();
|
|
49
|
+
return { signal, dispose: () => clearTimeout(timer) };
|
|
36
50
|
}
|
|
37
51
|
async function sleep(ms, signal) {
|
|
38
52
|
return new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getIndexMetadata } from './chunk-
|
|
2
|
-
import { fnv1a } from './chunk-
|
|
1
|
+
import { getIndexMetadata } from './chunk-BBIAUHAB.mjs';
|
|
2
|
+
import { fnv1a } from './chunk-MS746XNY.mjs';
|
|
3
3
|
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
4
4
|
|
|
5
5
|
// src/distribution/cluster-node/routable-allocation.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { loadFailed, cachedFileBytes, COLD_LOAD_WAIT_WITHOUT_SEARCH_MS, readWholeSectionChecked, checkEverySectionPage, readFileRange, openPagedFile, readCacheOfThisThread, createSectionReader, closePagedFile, COLD_GRAPH_PART_VECTORS, decodeSections, readListedFile, requireListedChecksum, requireListedSize, SEGMENT_PAGE_BYTES, RECORD_PAGE_BYTES, failNativePage, COLD_WALK_NODES_READ_AHEAD } from './chunk-
|
|
1
|
+
import { loadFailed, cachedFileBytes, COLD_LOAD_WAIT_WITHOUT_SEARCH_MS, readWholeSectionChecked, checkEverySectionPage, readFileRange, openPagedFile, readCacheOfThisThread, createSectionReader, closePagedFile, COLD_GRAPH_PART_VECTORS, decodeSections, readListedFile, requireListedChecksum, requireListedSize, SEGMENT_PAGE_BYTES, RECORD_PAGE_BYTES, failNativePage, COLD_WALK_NODES_READ_AHEAD } from './chunk-EALKCTWH.mjs';
|
|
2
2
|
import { isDead, VECTOR_FILE_PAYLOAD_VERSION, bytesToVectors, decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, requireBoundedUpperLists, osqRecordBytes, osqBitsOf, countDead, magnitude, rescoreDepth, defaultEfSearch, computeCodeBlockLayout, toScore, osqQuantize, createOsqScratch, stageQueryLevels, scalarQueryProducts, readTrailer, osqEstimate, osqDistance, toDistance, createFixedBuffer } from './chunk-R724DJSG.mjs';
|
|
3
|
-
import { HEADER_SIZE, openChecksummedEnvelope, crc32, readHeader } from './chunk-
|
|
4
|
-
import { yieldToEventLoop, compareScores } from './chunk-
|
|
5
|
-
import { decode, decodeMulti } from './chunk-
|
|
3
|
+
import { HEADER_SIZE, openChecksummedEnvelope, crc32, readHeader } from './chunk-WIT6B5OB.mjs';
|
|
4
|
+
import { yieldToEventLoop, compareScores } from './chunk-MS746XNY.mjs';
|
|
5
|
+
import { decode, decodeMulti } from './chunk-5GYGHPCH.mjs';
|
|
6
6
|
import { signalOfSearch, requireSearchActive } from './chunk-FJXJZUWF.mjs';
|
|
7
7
|
import { MIN_M, MAX_M, MAX_LAYER_CAP } from './chunk-ZXX5GZEX.mjs';
|
|
8
8
|
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
@@ -6,6 +6,11 @@ var DIRECTORY_IDENTITY_CHECK_INTERVAL_MS = 1e3;
|
|
|
6
6
|
var DIRECTORY_LOCK_ATTEMPTS = 3;
|
|
7
7
|
var DIRECTORY_LOCK_SETTLE_MS = 50;
|
|
8
8
|
var DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS = 1e3;
|
|
9
|
+
var HELD_FILE_RETRY_WINDOW_MS = 2e3;
|
|
10
|
+
var HELD_FILE_RETRY_FIRST_PAUSE_MS = 1;
|
|
11
|
+
var HELD_FILE_RETRY_LONGEST_PAUSE_MS = 250;
|
|
12
|
+
var INDEXEDDB_BLOCK_BYTES = 32768;
|
|
13
|
+
var INDEXEDDB_CACHED_BLOCKS = 64;
|
|
9
14
|
var DEFAULT_SEGMENT_MAX_BYTES = 67108864;
|
|
10
15
|
var DEFAULT_COMPACTION_THRESHOLD = 12;
|
|
11
16
|
var COMPACTION_LARGEST_MERGED_DOCUMENT_COUNT = 2e5;
|
|
@@ -22,4 +27,4 @@ var CHECKPOINT_WORKER_HEARTBEAT_MS = 5e3;
|
|
|
22
27
|
var CHECKPOINT_WORKER_IDLE_MS = 5e3;
|
|
23
28
|
var CHECKPOINT_TIMEOUT_RECOVERY_BACKOFF_MS = 50;
|
|
24
29
|
|
|
25
|
-
export { CHECKPOINT_TIMEOUT_RECOVERY_BACKOFF_MS, CHECKPOINT_WORKER_HEARTBEAT_MS, CHECKPOINT_WORKER_IDLE_MS, CHECKPOINT_WORKER_TIMEOUT_MS, COMPACTION_LARGEST_MERGED_DOCUMENT_COUNT, DEFAULT_ASYNC_FLUSH_INTERVAL_MS, DEFAULT_CHECKPOINT_INTERVAL_MS, DEFAULT_CHECKPOINT_MUTATION_THRESHOLD, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_REWRITE_BYTES_PER_CHECKPOINT, DEFAULT_SEGMENT_MAX_BYTES, DIRECTORY_IDENTITY_CHECK_INTERVAL_MS, DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS, DIRECTORY_LOCK_SETTLE_MS, LOG_RECORDS_PER_CHECKPOINT, REWRITE_ABOVE_REMOVED_DOCUMENT_SHARE, SEGMENT_FILE_FRAMING_SLACK_BYTES, SEGMENT_TOKEN_TABLE_SHARE_OF_FILE, WHOLE_PARTITION_LARGEST_DOCUMENT_COUNT, WHOLE_PARTITION_MIN_CHANGED_SHARE, WRITES_STALL_ABOVE_UNCHECKPOINTED_BYTES };
|
|
30
|
+
export { CHECKPOINT_TIMEOUT_RECOVERY_BACKOFF_MS, CHECKPOINT_WORKER_HEARTBEAT_MS, CHECKPOINT_WORKER_IDLE_MS, CHECKPOINT_WORKER_TIMEOUT_MS, COMPACTION_LARGEST_MERGED_DOCUMENT_COUNT, DEFAULT_ASYNC_FLUSH_INTERVAL_MS, DEFAULT_CHECKPOINT_INTERVAL_MS, DEFAULT_CHECKPOINT_MUTATION_THRESHOLD, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_REWRITE_BYTES_PER_CHECKPOINT, DEFAULT_SEGMENT_MAX_BYTES, DIRECTORY_IDENTITY_CHECK_INTERVAL_MS, DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS, DIRECTORY_LOCK_SETTLE_MS, HELD_FILE_RETRY_FIRST_PAUSE_MS, HELD_FILE_RETRY_LONGEST_PAUSE_MS, HELD_FILE_RETRY_WINDOW_MS, INDEXEDDB_BLOCK_BYTES, INDEXEDDB_CACHED_BLOCKS, LOG_RECORDS_PER_CHECKPOINT, REWRITE_ABOVE_REMOVED_DOCUMENT_SHARE, SEGMENT_FILE_FRAMING_SLACK_BYTES, SEGMENT_TOKEN_TABLE_SHARE_OF_FILE, WHOLE_PARTITION_LARGEST_DOCUMENT_COUNT, WHOLE_PARTITION_MIN_CHANGED_SHARE, WRITES_STALL_ABOVE_UNCHECKPOINTED_BYTES };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { encode } from './chunk-S5QMWECL.mjs';
|
|
2
2
|
import { oneSyncChangeAtATime } from './chunk-V6EUBAIT.mjs';
|
|
3
|
-
import { openChecksummedEnvelope, packChecksummedEnvelope } from './chunk-
|
|
4
|
-
import { rulesOfStoredSynonyms, configurationPayloadOf, withOpenIndex, emitSyncChange, validQueryFilter, createPartitionIndex, prepareDocumentVectors, createPatternWorkMeter, resolvePartitionInsertOptions } from './chunk-
|
|
5
|
-
import { decode } from './chunk-
|
|
3
|
+
import { openChecksummedEnvelope, packChecksummedEnvelope } from './chunk-WIT6B5OB.mjs';
|
|
4
|
+
import { rulesOfStoredSynonyms, configurationPayloadOf, withOpenIndex, emitSyncChange, validQueryFilter, createPartitionIndex, prepareDocumentVectors, createPatternWorkMeter, resolvePartitionInsertOptions } from './chunk-MS746XNY.mjs';
|
|
5
|
+
import { decode } from './chunk-5GYGHPCH.mjs';
|
|
6
6
|
import { newSyncEpoch, isSyncEpoch } from './chunk-BUMREPLU.mjs';
|
|
7
7
|
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
8
8
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { responseStopOf, sendRelayed,
|
|
2
|
-
import { SYNC_CLOSE_GOING_AWAY
|
|
3
|
-
import { importOptionalReads, loadSortingFor, holdsQuotedText, loadQueryCode, executeQuery, lazyQueryBinding, executePreflight, resolveProjection, projectionKeepsField, loadRerankRuntime, setNestedValue } from './chunk-
|
|
4
|
-
import { loadedMessagePack, loadMessagePack, extractVectorFieldsFromSchema } from './chunk-
|
|
1
|
+
import { responseStopOf, sendRelayed, readQueryBody, withServerQueryLimits, requestSignal, respondJson, encodeQueryResult, respondError, loadUWebSockets, childAppOf, createRouteRunner, corsHeaderReader, createSharedBodyBudget, createSharedRequestGate, registerFeedRoute, SYNC_FEED_ROUTE, CHANGES_FEED_ROUTE, registerServerRoutes, closeWhenTheProcessExits, acknowledgeThreadClose, statusLine, sendError, REQUEST_THREAD_MOVE_AFTER_MS, MAX_LONG_QUERIES_IN_FLIGHT, LeavingResponse, refuseAndClose, serverRoutes, createDocumentReadHandlers, SERVER_CAPABILITIES, versionReport, threadCloseRequested, departureConfirmed, serverCloseDeadline, REQUEST_THREAD_DRAIN_DEADLINE_MS, departureConfirmation, serverCloseSignalled, stopResponse, parseJsonObject, validateSuggest, rejectInvalid, isMainFeedNote, SEARCH_CLOCK_SAMPLE_UNITS, REQUEST_THREAD_DEPARTURE_DRAIN_MS, awaitDepartureConfirmation } from './chunk-4GCHJ3XD.mjs';
|
|
2
|
+
import { SYNC_CLOSE_GOING_AWAY } from './chunk-TACP6VK6.mjs';
|
|
3
|
+
import { importOptionalReads, loadSortingFor, holdsQuotedText, loadQueryCode, executeQuery, lazyQueryBinding, executePreflight, resolveProjection, projectionKeepsField, loadRerankRuntime, setNestedValue } from './chunk-MS746XNY.mjs';
|
|
4
|
+
import { loadedMessagePack, loadMessagePack, extractVectorFieldsFromSchema } from './chunk-4WQNWAQE.mjs';
|
|
5
5
|
import { answerFromOneState } from './chunk-FJXJZUWF.mjs';
|
|
6
6
|
import { ServerErrorCodes, ErrorCodes, NarsilError, isNarsilError } from './chunk-ZKOQR7EA.mjs';
|
|
7
7
|
|
|
8
8
|
// src/server/request-threads/feed-relay.ts
|
|
9
|
-
function threadFeedGateway(port, relay, feed) {
|
|
9
|
+
function threadFeedGateway(port, relay, feed, canRespond) {
|
|
10
10
|
const sockets = /* @__PURE__ */ new Map();
|
|
11
11
|
function post(note, transfer = []) {
|
|
12
12
|
try {
|
|
@@ -16,6 +16,7 @@ function threadFeedGateway(port, relay, feed) {
|
|
|
16
16
|
}
|
|
17
17
|
const onMessage = (message) => {
|
|
18
18
|
if (!isMainFeedNote(message)) return;
|
|
19
|
+
if (!canRespond()) return;
|
|
19
20
|
const socket = sockets.get(message.feedId);
|
|
20
21
|
if (socket === void 0) return;
|
|
21
22
|
if (message.type === "feed-close") {
|
|
@@ -738,120 +739,6 @@ function createThreadReadEngine(options) {
|
|
|
738
739
|
};
|
|
739
740
|
}
|
|
740
741
|
|
|
741
|
-
// src/server/request-threads/leaving-response.ts
|
|
742
|
-
function refuseAndClose(res, status, envelope) {
|
|
743
|
-
const payload = encodeJson(envelope);
|
|
744
|
-
res.cork(() => {
|
|
745
|
-
res.writeStatus(statusLine(status)).writeHeader("Content-Type", "application/json").writeHeader("Connection", "close").end(payload, true);
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
var LeavingResponse = class {
|
|
749
|
-
constructor(res, leaving) {
|
|
750
|
-
this.res = res;
|
|
751
|
-
this.leaving = leaving;
|
|
752
|
-
}
|
|
753
|
-
headStarted = false;
|
|
754
|
-
closesConnection = false;
|
|
755
|
-
finished = false;
|
|
756
|
-
onFinish = null;
|
|
757
|
-
get isFinished() {
|
|
758
|
-
return this.finished;
|
|
759
|
-
}
|
|
760
|
-
whenFinished(callback) {
|
|
761
|
-
if (this.finished) callback();
|
|
762
|
-
else this.onFinish = callback;
|
|
763
|
-
}
|
|
764
|
-
refuse(status, envelope) {
|
|
765
|
-
if (this.finished) return;
|
|
766
|
-
if (this.headStarted) {
|
|
767
|
-
this.close();
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
refuseAndClose(this.res, status, envelope);
|
|
771
|
-
this.headStarted = true;
|
|
772
|
-
this.finish();
|
|
773
|
-
}
|
|
774
|
-
cork(callback) {
|
|
775
|
-
this.res.cork(callback);
|
|
776
|
-
return this;
|
|
777
|
-
}
|
|
778
|
-
writeStatus(status) {
|
|
779
|
-
this.res.writeStatus(status);
|
|
780
|
-
this.startHead();
|
|
781
|
-
return this;
|
|
782
|
-
}
|
|
783
|
-
writeHeader(key, value) {
|
|
784
|
-
this.startHead();
|
|
785
|
-
this.res.writeHeader(key, value);
|
|
786
|
-
return this;
|
|
787
|
-
}
|
|
788
|
-
end(body, closeConnection) {
|
|
789
|
-
this.startHead();
|
|
790
|
-
this.res.end(body, closeConnection === true || this.closesConnection);
|
|
791
|
-
this.finish();
|
|
792
|
-
return this;
|
|
793
|
-
}
|
|
794
|
-
write(chunk) {
|
|
795
|
-
this.startHead();
|
|
796
|
-
return this.res.write(chunk);
|
|
797
|
-
}
|
|
798
|
-
pause() {
|
|
799
|
-
this.res.pause();
|
|
800
|
-
}
|
|
801
|
-
resume() {
|
|
802
|
-
this.res.resume();
|
|
803
|
-
}
|
|
804
|
-
close() {
|
|
805
|
-
this.res.close();
|
|
806
|
-
this.finish();
|
|
807
|
-
return this;
|
|
808
|
-
}
|
|
809
|
-
endWithoutBody() {
|
|
810
|
-
this.startHead();
|
|
811
|
-
this.res.endWithoutBody();
|
|
812
|
-
this.finish();
|
|
813
|
-
return this;
|
|
814
|
-
}
|
|
815
|
-
tryEnd(body, totalSize) {
|
|
816
|
-
this.startHead();
|
|
817
|
-
const result = this.res.tryEnd(body, totalSize);
|
|
818
|
-
if (result[1]) this.finish();
|
|
819
|
-
return result;
|
|
820
|
-
}
|
|
821
|
-
getWriteOffset() {
|
|
822
|
-
return this.res.getWriteOffset();
|
|
823
|
-
}
|
|
824
|
-
onWritable(handler) {
|
|
825
|
-
this.res.onWritable(handler);
|
|
826
|
-
return this;
|
|
827
|
-
}
|
|
828
|
-
onAborted(handler) {
|
|
829
|
-
this.res.onAborted(handler);
|
|
830
|
-
return this;
|
|
831
|
-
}
|
|
832
|
-
onData(handler) {
|
|
833
|
-
this.res.onData(handler);
|
|
834
|
-
return this;
|
|
835
|
-
}
|
|
836
|
-
getRemoteAddressAsText() {
|
|
837
|
-
return this.res.getRemoteAddressAsText();
|
|
838
|
-
}
|
|
839
|
-
startHead() {
|
|
840
|
-
if (this.headStarted) return;
|
|
841
|
-
this.headStarted = true;
|
|
842
|
-
if (!this.leaving()) return;
|
|
843
|
-
this.closesConnection = true;
|
|
844
|
-
this.res.writeHeader("Connection", "close");
|
|
845
|
-
}
|
|
846
|
-
finish() {
|
|
847
|
-
if (this.finished) return;
|
|
848
|
-
this.finished = true;
|
|
849
|
-
const callback = this.onFinish;
|
|
850
|
-
this.onFinish = null;
|
|
851
|
-
callback?.();
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
|
|
855
742
|
// src/server/request-threads/thread-departure.ts
|
|
856
743
|
var DEPARTURE_REFUSAL = {
|
|
857
744
|
error: {
|
|
@@ -970,11 +857,17 @@ function watchForDeparture(options) {
|
|
|
970
857
|
let finishing = false;
|
|
971
858
|
let draining = false;
|
|
972
859
|
let closing = false;
|
|
860
|
+
let serverClosing = false;
|
|
973
861
|
let drained = null;
|
|
974
862
|
function closeOnce() {
|
|
975
863
|
if (active === state) active = null;
|
|
976
864
|
close();
|
|
977
865
|
}
|
|
866
|
+
function canRespond() {
|
|
867
|
+
if (!threadCloseRequested(options.closeAtExit)) return true;
|
|
868
|
+
closeOnce();
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
978
871
|
function leaving() {
|
|
979
872
|
return departing || draining || departureConfirmed(departure);
|
|
980
873
|
}
|
|
@@ -989,13 +882,19 @@ function watchForDeparture(options) {
|
|
|
989
882
|
async function drainRunning() {
|
|
990
883
|
draining = true;
|
|
991
884
|
if (!departureConfirmed(departure)) relay.announceDeparture();
|
|
992
|
-
|
|
885
|
+
let deadline = serverCloseDeadline(options.serverClose) ?? Date.now() + REQUEST_THREAD_DRAIN_DEADLINE_MS;
|
|
993
886
|
await settledBy(departureConfirmation(departure), deadline);
|
|
994
|
-
|
|
887
|
+
do {
|
|
888
|
+
deadline = serverCloseDeadline(options.serverClose) ?? deadline;
|
|
889
|
+
await settledBy(idle(), deadline);
|
|
890
|
+
if (Date.now() >= deadline && deadline === (serverCloseDeadline(options.serverClose) ?? deadline)) break;
|
|
891
|
+
await pause(Math.min(REQUEST_THREAD_DEPARTURE_DRAIN_MS, Math.max(0, deadline - Date.now())));
|
|
892
|
+
} while (running.size > 0);
|
|
995
893
|
closing = true;
|
|
894
|
+
const refused = running.size > 0;
|
|
996
895
|
for (const request of running) refuse(request, DRAIN_DEADLINE_REFUSAL);
|
|
997
896
|
running.clear();
|
|
998
|
-
await pause(REQUEST_THREAD_DEPARTURE_DRAIN_MS);
|
|
897
|
+
if (refused && !serverCloseSignalled(options.serverClose)) await pause(REQUEST_THREAD_DEPARTURE_DRAIN_MS);
|
|
999
898
|
}
|
|
1000
899
|
const state = {
|
|
1001
900
|
begin() {
|
|
@@ -1025,6 +924,9 @@ function watchForDeparture(options) {
|
|
|
1025
924
|
if (departing) return DEPARTURE_REFUSAL;
|
|
1026
925
|
return closing ? CLOSING_REFUSAL : null;
|
|
1027
926
|
}
|
|
927
|
+
function refusalOnConnection() {
|
|
928
|
+
return refusalOnArrival() ?? (serverClosing || serverCloseSignalled(options.serverClose) ? CLOSING_REFUSAL : null);
|
|
929
|
+
}
|
|
1028
930
|
function refusingOnceDeparting(call) {
|
|
1029
931
|
return (...args) => {
|
|
1030
932
|
if (departing) throw departedError();
|
|
@@ -1032,8 +934,16 @@ function watchForDeparture(options) {
|
|
|
1032
934
|
};
|
|
1033
935
|
}
|
|
1034
936
|
return {
|
|
937
|
+
canRespond,
|
|
938
|
+
accept(res) {
|
|
939
|
+
if (!canRespond()) return false;
|
|
940
|
+
const refusal = refusalOnConnection();
|
|
941
|
+
if (refusal === null) return true;
|
|
942
|
+
refuseAndClose(res, 503, refusal);
|
|
943
|
+
return false;
|
|
944
|
+
},
|
|
1035
945
|
respondThrough(res) {
|
|
1036
|
-
return new LeavingResponse(res, leaving);
|
|
946
|
+
return new LeavingResponse(res, leaving, canRespond);
|
|
1037
947
|
},
|
|
1038
948
|
track(res, abort) {
|
|
1039
949
|
const request = { res, abort };
|
|
@@ -1088,7 +998,8 @@ function watchForDeparture(options) {
|
|
|
1088
998
|
listIndexes: refusingOnceDeparting(() => executor.listIndexes())
|
|
1089
999
|
};
|
|
1090
1000
|
},
|
|
1091
|
-
drain() {
|
|
1001
|
+
drain(refuseNewRequests) {
|
|
1002
|
+
if (refuseNewRequests) serverClosing = true;
|
|
1092
1003
|
if (departing) return Promise.resolve();
|
|
1093
1004
|
if (drained === null) drained = drainRunning();
|
|
1094
1005
|
return drained;
|
|
@@ -1125,7 +1036,7 @@ async function answerMoved(ctx, params, limits, options) {
|
|
|
1125
1036
|
try {
|
|
1126
1037
|
const answer = await options.answerHere(
|
|
1127
1038
|
ctx.params[0],
|
|
1128
|
-
|
|
1039
|
+
withServerQueryLimits(params, limits),
|
|
1129
1040
|
requestSignal(ctx.abort)
|
|
1130
1041
|
);
|
|
1131
1042
|
respondJson(ctx, "hits" in answer ? encodeQueryResult(answer) : answer);
|
|
@@ -1138,20 +1049,14 @@ async function answerMoved(ctx, params, limits, options) {
|
|
|
1138
1049
|
function searchHandler(options) {
|
|
1139
1050
|
const { fallback, limits, allowRegex, staysOnThread, answer } = options;
|
|
1140
1051
|
return async (ctx) => {
|
|
1141
|
-
const params =
|
|
1052
|
+
const params = readQueryBody(ctx, limits, allowRegex);
|
|
1142
1053
|
if (!params) return;
|
|
1143
|
-
const failure = validateQuery(params, limits);
|
|
1144
|
-
if (failure) {
|
|
1145
|
-
rejectInvalid(ctx, failure);
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
if (refuseRegex(ctx, params.filters, allowRegex)) return;
|
|
1149
1054
|
if (!staysOnThread(ctx.params[0], params)) {
|
|
1150
1055
|
await fallback(ctx);
|
|
1151
1056
|
return;
|
|
1152
1057
|
}
|
|
1153
1058
|
try {
|
|
1154
|
-
const result = await answer(ctx.params[0],
|
|
1059
|
+
const result = await answer(ctx.params[0], withServerQueryLimits(params, limits), requestSignal(ctx.abort));
|
|
1155
1060
|
respondJson(ctx, "hits" in result ? encodeQueryResult(result) : result);
|
|
1156
1061
|
} catch (err) {
|
|
1157
1062
|
if (ctx.abort.aborted) return;
|
|
@@ -1163,7 +1068,7 @@ function searchHandler(options) {
|
|
|
1163
1068
|
}
|
|
1164
1069
|
function suggestHandler(local, fallback) {
|
|
1165
1070
|
return async (ctx) => {
|
|
1166
|
-
const params =
|
|
1071
|
+
const params = parseJsonObject(ctx);
|
|
1167
1072
|
if (!params) return;
|
|
1168
1073
|
const failure = validateSuggest(params);
|
|
1169
1074
|
if (failure) {
|
|
@@ -1232,6 +1137,10 @@ async function serveRequests(executor, settings) {
|
|
|
1232
1137
|
const app = uws.App();
|
|
1233
1138
|
const child = childAppOf(app);
|
|
1234
1139
|
if (child === null) throw new Error("This uWebSockets.js build offers no child apps");
|
|
1140
|
+
const closeAtExit = new Int32Array(settings.closeAtExit);
|
|
1141
|
+
const close = () => {
|
|
1142
|
+
if (servingApp?.app === child) closeRequestThread();
|
|
1143
|
+
};
|
|
1235
1144
|
const relay = createRelayClient(settings.port, settings.touchIntervalMs);
|
|
1236
1145
|
const longQueries = routeLongQueries(
|
|
1237
1146
|
settings.port,
|
|
@@ -1242,7 +1151,9 @@ async function serveRequests(executor, settings) {
|
|
|
1242
1151
|
const departure = watchForDeparture({
|
|
1243
1152
|
relay,
|
|
1244
1153
|
departure: new Int32Array(settings.departure),
|
|
1245
|
-
|
|
1154
|
+
serverClose: new BigInt64Array(settings.serverClose),
|
|
1155
|
+
closeAtExit,
|
|
1156
|
+
close
|
|
1246
1157
|
});
|
|
1247
1158
|
const local = createThreadReadEngine({
|
|
1248
1159
|
executor: departure.guardExecutor(executor),
|
|
@@ -1253,6 +1164,7 @@ async function serveRequests(executor, settings) {
|
|
|
1253
1164
|
moveAfterMs: () => longQueries.moveAfterMs()
|
|
1254
1165
|
});
|
|
1255
1166
|
const run = createRouteRunner({
|
|
1167
|
+
accept: departure.accept,
|
|
1256
1168
|
authorize: settings.authorizes ? (context) => relay.authorize(context) : void 0,
|
|
1257
1169
|
gate: createSharedRequestGate(settings.gate, settings.maxConcurrentRequests, settings.gateSlot),
|
|
1258
1170
|
bodyBudget: createSharedBodyBudget(settings.bodyBudget, settings.limits.maxBodyBytesInFlight, settings.gateSlot),
|
|
@@ -1263,30 +1175,37 @@ async function serveRequests(executor, settings) {
|
|
|
1263
1175
|
const forwarded = relayedHandlers(relay, settings.limits);
|
|
1264
1176
|
const handlers = guardEveryRoute(threadHandlers(local, forwarded, longQueries, settings), forwarded, departure);
|
|
1265
1177
|
const feeds = settings.feeds.map((feed) => {
|
|
1266
|
-
const gateway = threadFeedGateway(settings.port, relay, feed);
|
|
1267
|
-
registerFeedRoute(
|
|
1178
|
+
const gateway = threadFeedGateway(settings.port, relay, feed, departure.canRespond);
|
|
1179
|
+
registerFeedRoute(
|
|
1180
|
+
app,
|
|
1181
|
+
gateway,
|
|
1182
|
+
feed === "sync" ? SYNC_FEED_ROUTE : CHANGES_FEED_ROUTE,
|
|
1183
|
+
departure.accept,
|
|
1184
|
+
departure.canRespond
|
|
1185
|
+
);
|
|
1268
1186
|
return gateway;
|
|
1269
1187
|
});
|
|
1270
|
-
registerServerRoutes(app, run, handlers, settings.limits, settings.cors);
|
|
1271
|
-
servingApp = { app: child, relay, longQueries, feeds, departure };
|
|
1272
|
-
void closeWhenTheProcessExits(
|
|
1188
|
+
registerServerRoutes(app, run, handlers, settings.limits, settings.cors, departure.accept);
|
|
1189
|
+
servingApp = { app: child, relay, longQueries, feeds, departure, closeAtExit };
|
|
1190
|
+
void closeWhenTheProcessExits(closeAtExit, close);
|
|
1273
1191
|
return { descriptor: child.getDescriptor() };
|
|
1274
1192
|
}
|
|
1275
|
-
async function drainRequestThread() {
|
|
1193
|
+
async function drainRequestThread(refuseNewRequests) {
|
|
1276
1194
|
const serving = servingApp;
|
|
1277
1195
|
if (serving === null) return;
|
|
1278
|
-
await serving.departure.drain();
|
|
1279
|
-
closeRequestThread();
|
|
1196
|
+
await serving.departure.drain(refuseNewRequests);
|
|
1197
|
+
if (servingApp === serving) closeRequestThread();
|
|
1280
1198
|
}
|
|
1281
1199
|
function closeRequestThread() {
|
|
1282
1200
|
leaveWithoutDeparture();
|
|
1283
1201
|
if (servingApp === null) return;
|
|
1284
|
-
const { app, relay, longQueries, feeds } = servingApp;
|
|
1202
|
+
const { app, relay, longQueries, feeds, closeAtExit } = servingApp;
|
|
1285
1203
|
servingApp = null;
|
|
1286
1204
|
for (const gateway of feeds) gateway.close();
|
|
1287
1205
|
app.close();
|
|
1288
1206
|
longQueries.close();
|
|
1289
1207
|
relay.close();
|
|
1208
|
+
acknowledgeThreadClose(closeAtExit);
|
|
1290
1209
|
}
|
|
1291
1210
|
|
|
1292
1211
|
export { closeRequestThread, createRelayClient, createThreadReadEngine, drainRequestThread, isLongQueryPortNote, searchHandler, serveRequests };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { syncStorageOf, INDEX_CONFIGURATION_ENVELOPE_VERSION, MAX_SNAPSHOT_ANALYSIS_ATTEMPTS, encodeIndexConfiguration } from './chunk-
|
|
2
|
-
import { archiveLayout } from './chunk-
|
|
3
|
-
import { manifestFileRefs } from './chunk-
|
|
4
|
-
import { DIRECTORY_IDENTITY_CHECK_INTERVAL_MS } from './chunk-MSIN4NM3.mjs';
|
|
1
|
+
import { syncStorageOf, INDEX_CONFIGURATION_ENVELOPE_VERSION, MAX_SNAPSHOT_ANALYSIS_ATTEMPTS, encodeIndexConfiguration } from './chunk-SSITKQU6.mjs';
|
|
2
|
+
import { archiveLayout } from './chunk-XWPNRHTG.mjs';
|
|
3
|
+
import { manifestFileRefs } from './chunk-TANKI7TG.mjs';
|
|
5
4
|
import { oneSyncChangeAtATime } from './chunk-V6EUBAIT.mjs';
|
|
6
|
-
import { openChecksummedEnvelope } from './chunk-
|
|
7
|
-
import { withOpenIndex, emitEngineEvent } from './chunk-
|
|
8
|
-
import { decode } from './chunk-
|
|
5
|
+
import { openChecksummedEnvelope } from './chunk-WIT6B5OB.mjs';
|
|
6
|
+
import { withOpenIndex, emitEngineEvent } from './chunk-MS746XNY.mjs';
|
|
7
|
+
import { decode } from './chunk-5GYGHPCH.mjs';
|
|
9
8
|
import { isSyncEpoch } from './chunk-BUMREPLU.mjs';
|
|
9
|
+
import { DIRECTORY_IDENTITY_CHECK_INTERVAL_MS } from './chunk-S3JHYPH7.mjs';
|
|
10
10
|
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
11
11
|
|
|
12
12
|
// src/persistence/durability/directory-watch.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadStorageCode, resolvePartialWordAnalysis, resolvePartitionInsertOptions, yieldToEventLoop, createPartitionIndex, writePartitionDocument } from './chunk-
|
|
1
|
+
import { loadStorageCode, resolvePartialWordAnalysis, resolvePartitionInsertOptions, yieldToEventLoop, createPartitionIndex, writePartitionDocument } from './chunk-MS746XNY.mjs';
|
|
2
2
|
|
|
3
3
|
// src/partitioning/constants.ts
|
|
4
4
|
var REBALANCE_CHUNK_SIZE = 1e3;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { bindResponseStop, sendError, RELAY_STREAM_CHUNKS_IN_FLIGHT } from './chunk-
|
|
2
|
-
import { ServerErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
1
|
+
import { bindResponseStop, toHttpError, sendError, RELAY_STREAM_CHUNKS_IN_FLIGHT } from './chunk-4GCHJ3XD.mjs';
|
|
3
2
|
import { rm } from 'fs/promises';
|
|
4
3
|
import path from 'path';
|
|
5
4
|
|
|
@@ -207,8 +206,9 @@ async function answerRequest(handler, request, port, streams) {
|
|
|
207
206
|
};
|
|
208
207
|
try {
|
|
209
208
|
await handler(ctx);
|
|
210
|
-
} catch {
|
|
211
|
-
|
|
209
|
+
} catch (err) {
|
|
210
|
+
const { status, body } = toHttpError(err);
|
|
211
|
+
sendError(ctx.res, status, body.code, body.message, body.details);
|
|
212
212
|
}
|
|
213
213
|
captured.finishUnanswered();
|
|
214
214
|
const answered = await captured.done;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VERSION, GROUP_PATTERN_SOURCE, loadGzip } from './chunk-
|
|
2
|
-
import { flattenSchema } from './chunk-
|
|
1
|
+
import { VERSION, GROUP_PATTERN_SOURCE, loadGzip } from './chunk-MS746XNY.mjs';
|
|
2
|
+
import { flattenSchema } from './chunk-4WQNWAQE.mjs';
|
|
3
3
|
import { NATIVE_CRC32_MIN_BYTES, MAX_FILE_BYTES, CHECKSUM_YIELD_CHUNK_BYTES } from './chunk-4PY4JYMY.mjs';
|
|
4
4
|
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
5
5
|
import { encode } from '@msgpack/msgpack';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isValidInteger, isRecord } from './chunk-
|
|
1
|
+
import { isValidInteger, isRecord } from './chunk-BBIAUHAB.mjs';
|
|
2
2
|
import { MAX_REPLICATION_FACTOR, MAX_PARTITION_COUNT } from './chunk-JDDXV6UF.mjs';
|
|
3
|
-
import { openChecksummedEnvelope, packChecksummedEnvelope, MAX_HISTORY_FILE_BYTES } from './chunk-
|
|
4
|
-
import { decode } from './chunk-
|
|
3
|
+
import { openChecksummedEnvelope, packChecksummedEnvelope, MAX_HISTORY_FILE_BYTES } from './chunk-WIT6B5OB.mjs';
|
|
4
|
+
import { decode } from './chunk-5GYGHPCH.mjs';
|
|
5
5
|
import { isSyncEpoch } from './chunk-BUMREPLU.mjs';
|
|
6
6
|
import { joinChunks } from './chunk-GR5GMFJJ.mjs';
|
|
7
7
|
import { MAX_FILE_BYTES } from './chunk-4PY4JYMY.mjs';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MAX_SEGMENT_ID, MANIFEST_ENVELOPE_VERSION, EARLIER_SEGMENT_MANIFEST_VERSION, SEGMENT_MANIFEST_VERSION, MAX_SEGMENTS_PER_PARTITION, segmentKey, manifestFileRefs, graphPartKey, vectorFileKey } from './chunk-
|
|
1
|
+
import { MAX_SEGMENT_ID, MANIFEST_ENVELOPE_VERSION, EARLIER_SEGMENT_MANIFEST_VERSION, SEGMENT_MANIFEST_VERSION, MAX_SEGMENTS_PER_PARTITION, segmentKey, manifestFileRefs, graphPartKey, vectorFileKey } from './chunk-TANKI7TG.mjs';
|
|
2
2
|
import { VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-R724DJSG.mjs';
|
|
3
|
-
import { openChecksummedEnvelope, HEADER_SIZE, QUERY_HISTORY_ARCHIVE_PREFIX, MAX_HISTORY_FILE_BYTES } from './chunk-
|
|
4
|
-
import { decode } from './chunk-
|
|
5
|
-
import { requireValidFieldTypes } from './chunk-
|
|
3
|
+
import { openChecksummedEnvelope, HEADER_SIZE, QUERY_HISTORY_ARCHIVE_PREFIX, MAX_HISTORY_FILE_BYTES } from './chunk-WIT6B5OB.mjs';
|
|
4
|
+
import { decode } from './chunk-5GYGHPCH.mjs';
|
|
5
|
+
import { requireValidFieldTypes } from './chunk-4WQNWAQE.mjs';
|
|
6
6
|
import { MAX_FILE_BYTES } from './chunk-4PY4JYMY.mjs';
|
|
7
7
|
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { openCountsFile } from './chunk-
|
|
2
|
-
import { SCRAMBLED_ID_BYTES } from './chunk-
|
|
1
|
+
import { openCountsFile } from './chunk-KX3OP6VP.mjs';
|
|
2
|
+
import { SCRAMBLED_ID_BYTES } from './chunk-WIT6B5OB.mjs';
|
|
3
3
|
export { encode } from '@msgpack/msgpack';
|
|
4
4
|
|
|
5
5
|
function bindSuggestionsHost(_host, _msgpack, _suggestionStore) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { HELD_FILE_RETRY_LONGEST_PAUSE_MS, HELD_FILE_RETRY_FIRST_PAUSE_MS, HELD_FILE_RETRY_WINDOW_MS } from './chunk-S3JHYPH7.mjs';
|
|
2
|
+
|
|
3
|
+
// src/persistence/durability/node-fs.ts
|
|
4
|
+
var cachedFs = null;
|
|
5
|
+
var cachedPath = null;
|
|
6
|
+
async function getFs() {
|
|
7
|
+
if (cachedFs === null) {
|
|
8
|
+
cachedFs = await import('fs/promises');
|
|
9
|
+
}
|
|
10
|
+
return cachedFs;
|
|
11
|
+
}
|
|
12
|
+
async function getPath() {
|
|
13
|
+
if (cachedPath === null) {
|
|
14
|
+
cachedPath = await import('path');
|
|
15
|
+
}
|
|
16
|
+
return cachedPath;
|
|
17
|
+
}
|
|
18
|
+
function heldByAnotherHandle(error, retriesMissing) {
|
|
19
|
+
if (typeof process === "undefined" || process.platform !== "win32") return false;
|
|
20
|
+
const code = error?.code;
|
|
21
|
+
return code === "EPERM" || code === "EBUSY" || retriesMissing && code === "ENOENT";
|
|
22
|
+
}
|
|
23
|
+
function pause(ms) {
|
|
24
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
25
|
+
}
|
|
26
|
+
async function retriedWhileHeld(operation, retriesMissing) {
|
|
27
|
+
let deadline = null;
|
|
28
|
+
let wait = HELD_FILE_RETRY_FIRST_PAUSE_MS;
|
|
29
|
+
for (; ; ) {
|
|
30
|
+
try {
|
|
31
|
+
await operation();
|
|
32
|
+
return;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (!heldByAnotherHandle(error, retriesMissing)) throw error;
|
|
35
|
+
const now = performance.now();
|
|
36
|
+
deadline ??= now + HELD_FILE_RETRY_WINDOW_MS;
|
|
37
|
+
if (now + wait >= deadline) throw error;
|
|
38
|
+
}
|
|
39
|
+
await pause(wait);
|
|
40
|
+
wait = Math.min(2 * wait, HELD_FILE_RETRY_LONGEST_PAUSE_MS);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function renameReplacing(from, to) {
|
|
44
|
+
const fs = await getFs();
|
|
45
|
+
await retriedWhileHeld(() => fs.rename(from, to), true);
|
|
46
|
+
}
|
|
47
|
+
async function renameUnlessMissing(from, to) {
|
|
48
|
+
const fs = await getFs();
|
|
49
|
+
await retriedWhileHeld(() => fs.rename(from, to), false);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { getFs, getPath, renameReplacing, renameUnlessMissing };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PartitionConfig, B as BM25Params, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-
|
|
2
|
-
import { o as SnapshotOptions, V as VectorMaintenanceResult, B as BatchResult, L as ListParams,
|
|
1
|
+
import { P as PartitionConfig, B as BM25Params, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-CFnQ-WI3.js';
|
|
2
|
+
import { o as SnapshotOptions, V as VectorMaintenanceResult, B as BatchResult, L as ListParams, v as ListResult, F as FollowChangesOptions, d as ChangesEvent, a as ChangePosition, h as ChangesStatus, g as ChangesSetting, I as IndexInfo, z as IndexStats, P as PartitionStatsResult, Q as QueryParams, t as QueryResult, y as PreflightResult, w as SuggestParams, x as SuggestResult, q as SyncStatus, p as SyncSetting } from './engine-DGG_yX0p.js';
|
|
3
3
|
import { a as SynonymRule } from './synonyms-CpOAHPa-.js';
|
|
4
|
-
import { f as TaskRecord, a as ChangeAnalysisBody, M as MemoryStatsResponse, m as CreateBackupBody, R as RestoreBackupBody, c as ImportResult, H as HttpIndexConfig, d as TaskListQuery, T as TaskListPage } from './tasks-
|
|
5
|
-
import { B as BackupListing } from './config-
|
|
4
|
+
import { f as TaskRecord, a as ChangeAnalysisBody, M as MemoryStatsResponse, m as CreateBackupBody, R as RestoreBackupBody, c as ImportResult, H as HttpIndexConfig, d as TaskListQuery, T as TaskListPage } from './tasks-B2MDjPL0.js';
|
|
5
|
+
import { B as BackupListing } from './config-DL_nkguq.js';
|
|
6
6
|
import { d as QuerySuggestionsSetting, e as QuerySuggestionsStatus, f as RecordQueryResult, c as QuerySuggestionsPreview, M as ManualQuerySuggestion } from './query-suggestions-CBYkrQ5T.js';
|
|
7
7
|
|
|
8
8
|
/**
|