gitnexus 1.6.4-rc.66 → 1.6.4-rc.68

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.
@@ -36,6 +36,30 @@ export function resolveWorkerPoolOptions(options = {}) {
36
36
  timeoutBackoffFactor: positiveInteger(options.timeoutBackoffFactor) ?? DEFAULT_TIMEOUT_BACKOFF_FACTOR,
37
37
  };
38
38
  }
39
+ function waitForWorkerOnline(worker) {
40
+ return new Promise((resolve, reject) => {
41
+ const cleanup = () => {
42
+ worker.removeListener('online', onOnline);
43
+ worker.removeListener('error', onError);
44
+ worker.removeListener('exit', onExit);
45
+ };
46
+ const onOnline = () => {
47
+ cleanup();
48
+ resolve();
49
+ };
50
+ const onError = (err) => {
51
+ cleanup();
52
+ reject(err);
53
+ };
54
+ const onExit = (code) => {
55
+ cleanup();
56
+ reject(new Error(`Replacement worker exited with code ${code} before coming online`));
57
+ };
58
+ worker.once('online', onOnline);
59
+ worker.once('error', onError);
60
+ worker.once('exit', onExit);
61
+ });
62
+ }
39
63
  function estimateItemBytes(item) {
40
64
  if (typeof item !== 'object' || item === null)
41
65
  return 0;
@@ -128,8 +152,21 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
128
152
  const replaceWorker = async (workerIndex) => {
129
153
  const worker = workers[workerIndex];
130
154
  await worker?.terminate().catch(() => undefined);
131
- if (!stopped)
132
- workers[workerIndex] = new Worker(workerUrl);
155
+ if (stopped)
156
+ return;
157
+ const replacement = new Worker(workerUrl);
158
+ try {
159
+ await waitForWorkerOnline(replacement);
160
+ }
161
+ catch (err) {
162
+ await replacement.terminate().catch(() => undefined);
163
+ throw new Error(`Replacement worker ${workerIndex} failed to start: ${err instanceof Error ? err.message : String(err)}`);
164
+ }
165
+ if (stopped) {
166
+ await replacement.terminate().catch(() => undefined);
167
+ return;
168
+ }
169
+ workers[workerIndex] = replacement;
133
170
  };
134
171
  const fail = async (err) => {
135
172
  poolBroken = true;
@@ -245,7 +282,7 @@ export const createWorkerPool = (workerUrl, poolSize, options) => {
245
282
  await replaceWorker(workerIndex);
246
283
  }
247
284
  catch (err) {
248
- void fail(err instanceof Error ? err : new Error(`Worker replacement failed: ${err}`));
285
+ void fail(err instanceof Error ? err : new Error(String(err)));
249
286
  return;
250
287
  }
251
288
  finally {
@@ -13,7 +13,17 @@ export const isGitRepo = (repoPath) => {
13
13
  };
14
14
  export const getCurrentCommit = (repoPath) => {
15
15
  try {
16
- return execSync('git rev-parse HEAD', { cwd: repoPath }).toString().trim();
16
+ return execSync('git rev-parse HEAD', {
17
+ cwd: repoPath,
18
+ // Suppress stderr -- without an explicit stdio option, Node's execSync
19
+ // forwards the child's stderr to the parent process (documented behaviour).
20
+ // When repoPath is not inside a git worktree, git prints
21
+ // "fatal: not a git repository" to stderr, which leaks to the user's
22
+ // terminal even though the error is caught here (#1172).
23
+ stdio: ['ignore', 'pipe', 'ignore'],
24
+ })
25
+ .toString()
26
+ .trim();
17
27
  }
18
28
  catch {
19
29
  return '';
@@ -83,7 +93,13 @@ export const getRemoteUrl = (repoPath) => {
83
93
  */
84
94
  export const getGitRoot = (fromPath) => {
85
95
  try {
86
- const raw = execSync('git rev-parse --show-toplevel', { cwd: fromPath }).toString().trim();
96
+ const raw = execSync('git rev-parse --show-toplevel', {
97
+ cwd: fromPath,
98
+ // Suppress stderr -- see getCurrentCommit comment and #1172.
99
+ stdio: ['ignore', 'pipe', 'ignore'],
100
+ })
101
+ .toString()
102
+ .trim();
87
103
  // On Windows, git returns /d/Projects/Foo — path.resolve normalizes to D:\Projects\Foo
88
104
  return path.resolve(raw);
89
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.4-rc.66",
3
+ "version": "1.6.4-rc.68",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",