Skip to content

Commit ac12145

Browse files
authored
fix: context disposal race condition crash (#632)
* fix: context disposal race condition crash * fix: context shift edge cases * fix: use stderr for partial logs of at least warn level
1 parent f53ea51 commit ac12145

47 files changed

Lines changed: 165 additions & 51 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ node_modules
55
*.cpuprofile
66

77
/dist
8+
/tsconfig.tsbuildinfo
89
/docs-site
910
/docs/api
1011
/templates/packed

.vitepress/config.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ export default defineConfig({
414414
],
415415
module: ts.ModuleKind.ES2022,
416416
target: ts.ScriptTarget.ES2022,
417-
moduleDetection: ts.ModuleDetectionKind.Force
417+
moduleDetection: ts.ModuleDetectionKind.Force,
418+
rootDir: undefined
418419
},
419420
tsModule: ts
420421
}
@@ -468,6 +469,27 @@ export default defineConfig({
468469
detailedView: true,
469470
miniSearch: {
470471
searchOptions: {
472+
fuzzy: 0.05,
473+
tokenize(query: string) {
474+
const maxRemovedSpaces = 3;
475+
const words = query.match(/[\p{L}\p{N}]+/gu) ?? [];
476+
const terms = new Set(words);
477+
478+
for (let start = 0; start < words.length; start++) {
479+
let joined = words[start]!;
480+
481+
for (let removedSpaces = 1; removedSpaces <= maxRemovedSpaces; removedSpaces++) {
482+
const nextWord = words[start + removedSpaces];
483+
if (nextWord == null)
484+
break;
485+
486+
joined += nextWord;
487+
terms.add(joined);
488+
}
489+
}
490+
491+
return [...terms];
492+
},
471493
boostDocument(term, documentId, storedFields) {
472494
const firstTitle = (storedFields?.titles as string[])?.[0];
473495
if (firstTitle?.startsWith("Type Alias: "))

.vitepress/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
"noUncheckedIndexedAccess": true,
1616
"moduleDetection": "force",
1717
"skipLibCheck": true,
18-
"moduleResolution": "bundler",
18+
"moduleResolution": "node16",
1919
"resolveJsonModule": true,
2020
"strictNullChecks": true,
2121
"isolatedModules": true,
2222
"noEmit": false,
23+
"rootDir": "..",
2324
"outDir": "./dist",
2425
"strict": true,
2526
"sourceMap": true,

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export default defineConfig({
188188
allow: []
189189
}],
190190
"@typescript-eslint/explicit-member-accessibility": ["warn"],
191+
"@typescript-eslint/consistent-type-definitions": ["warn", "type"],
191192
"@stylistic/member-delimiter-style": ["warn", {
192193
multiline: {
193194
delimiter: "comma",

llama/addon/AddonModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ Napi::Value AddonModel::Dispose(const Napi::CallbackInfo& info) {
530530
return worker->GetPromise();
531531
} else {
532532
disposeMT();
533-
533+
534534
Napi::Promise::Deferred deferred = Napi::Promise::Deferred::New(info.Env());
535535
deferred.Resolve(info.Env().Undefined());
536536
return deferred.Promise();

llama/addon/addonGlobals.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <sstream>
22
#include <vector>
3+
#include <algorithm>
4+
#include <limits>
35
#include "addonGlobals.h"
46
#include "napi.h"
57

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/dist
2+
/tsconfig.tsbuildinfo

packages/@node-llama-cpp/linux-arm64/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"strictNullChecks": true,
1919
"isolatedModules": true,
2020
"noEmit": false,
21+
"rootDir": "./src",
2122
"outDir": "./dist",
2223
"strict": true,
2324
"sourceMap": false,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/dist
2+
/tsconfig.tsbuildinfo

packages/@node-llama-cpp/linux-armv7l/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"strictNullChecks": true,
1919
"isolatedModules": true,
2020
"noEmit": false,
21+
"rootDir": "./src",
2122
"outDir": "./dist",
2223
"strict": true,
2324
"sourceMap": false,

0 commit comments

Comments
 (0)