caveat-cli 0.16.0 → 0.16.1

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.
@@ -14547,23 +14547,35 @@ var simpleGit = gitInstanceFactory;
14547
14547
 
14548
14548
  // ../../packages/core/dist/gitRuntime.js
14549
14549
  var FOREGROUND_GIT_TIMEOUT_MS = 3e5;
14550
+ var BACKGROUND_GIT_TIMEOUT_MS = 3e4;
14551
+ var HTTP_HELPER_PREEMPT_MARGIN_MS = 5e3;
14552
+ var MIN_GIT_TIMEOUT_MS = HTTP_HELPER_PREEMPT_MARGIN_MS + 1e3;
14550
14553
  function createGit(baseDir, opts) {
14551
14554
  const timeoutMs = opts?.timeoutMs ?? FOREGROUND_GIT_TIMEOUT_MS;
14555
+ if (!Number.isFinite(timeoutMs) || timeoutMs < MIN_GIT_TIMEOUT_MS) {
14556
+ throw new Error(`git timeoutMs must be at least ${MIN_GIT_TIMEOUT_MS}`);
14557
+ }
14558
+ const lowSpeedTimeSeconds = Math.floor((timeoutMs - HTTP_HELPER_PREEMPT_MARGIN_MS) / 1e3);
14552
14559
  const env = {
14553
14560
  ...process.env,
14554
14561
  GIT_TERMINAL_PROMPT: "0",
14555
- GCM_INTERACTIVE: "Never"
14562
+ GCM_INTERACTIVE: "Never",
14563
+ // Git's GIT_HTTP_LOW_SPEED_* environment variables override the matching
14564
+ // config keys. Set both after inherited env so a caller cannot silently
14565
+ // disable the helper-side no-response bound.
14566
+ GIT_HTTP_LOW_SPEED_LIMIT: "1",
14567
+ GIT_HTTP_LOW_SPEED_TIME: String(lowSpeedTimeSeconds)
14556
14568
  };
14557
14569
  const options2 = {
14558
14570
  maxConcurrentProcesses: 1,
14559
14571
  timeout: { block: timeoutMs },
14560
14572
  // On Windows, killing the direct `git` child does not necessarily kill its
14561
- // `git-remote-http` descendant. Give the HTTP helper the same bounded
14562
- // inactivity policy so it terminates itself instead of retaining handles
14563
- // indefinitely after simple-git has already rejected the task.
14573
+ // `git-remote-http` descendant. This earlier HTTP transfer-rate bound lets
14574
+ // Git unwind its own helper first; it is not a general process-tree or
14575
+ // total elapsed-time guarantee.
14564
14576
  config: [
14565
14577
  "http.lowSpeedLimit=1",
14566
- `http.lowSpeedTime=${Math.max(1, Math.ceil(timeoutMs / 1e3))}`
14578
+ `http.lowSpeedTime=${lowSpeedTimeSeconds}`
14567
14579
  ],
14568
14580
  unsafe: unsafeAllowancesForInheritedEnv(env)
14569
14581
  };
@@ -14625,8 +14637,8 @@ async function communityPull(opts) {
14625
14637
  for (const entry of readdirSync5(opts.communityDir, { withFileTypes: true })) {
14626
14638
  if (!entry.isDirectory()) continue;
14627
14639
  const path = join5(opts.communityDir, entry.name);
14628
- const git = createGit(path);
14629
14640
  try {
14641
+ const git = createGit(path, { timeoutMs: opts.gitTimeoutMs });
14630
14642
  await git.raw(["fetch", "origin", "--force", "--depth", "1"]);
14631
14643
  await git.raw(["reset", "--hard", "FETCH_HEAD"]);
14632
14644
  await git.raw(["clean", "-ffdx"]);
@@ -15067,7 +15079,7 @@ async function assertPrivateRemotes(remoteUrls, opts) {
15067
15079
  return worst;
15068
15080
  }
15069
15081
  async function preflightSync(ownDir, opts = {}) {
15070
- const git = createGit(ownDir);
15082
+ const git = createGit(ownDir, { timeoutMs: opts.gitTimeoutMs });
15071
15083
  if (!await git.checkIsRepo()) {
15072
15084
  throw new SyncError("NOT_A_REPO", "own knowledge directory is not a git repository; run `caveat sync --init` first");
15073
15085
  }
@@ -15103,7 +15115,7 @@ async function reindexAndMark(opts) {
15103
15115
  }
15104
15116
  async function syncOwn(opts) {
15105
15117
  const preflight = await preflightSync(opts.ownDir, opts);
15106
- const git = createGit(preflight.ownDir);
15118
+ const git = createGit(preflight.ownDir, { timeoutMs: opts.gitTimeoutMs });
15107
15119
  const status = await git.status();
15108
15120
  if (opts.dryRun) {
15109
15121
  return {
@@ -15347,7 +15359,8 @@ async function runAutoSync(opts) {
15347
15359
  };
15348
15360
  const community = await communityPull({
15349
15361
  communityDir: opts.paths.communityDir,
15350
- logger: opts.logger
15362
+ logger: opts.logger,
15363
+ gitTimeoutMs: opts.gitTimeoutMs ?? BACKGROUND_GIT_TIMEOUT_MS
15351
15364
  });
15352
15365
  let own;
15353
15366
  if (ownSyncState.consecutiveFailureCount >= 3) {
@@ -15361,6 +15374,7 @@ async function runAutoSync(opts) {
15361
15374
  paths: opts.paths,
15362
15375
  logger: opts.logger,
15363
15376
  trustRemotePrivate: false,
15377
+ gitTimeoutMs: opts.gitTimeoutMs ?? BACKGROUND_GIT_TIMEOUT_MS,
15364
15378
  probeImpl: async (url) => {
15365
15379
  const probe = await probeAnonymousRead(url);
15366
15380
  lastProbe = probe;
@@ -17320,4 +17334,4 @@ strip-bom-string/index.js:
17320
17334
  js-yaml/dist/js-yaml.mjs:
17321
17335
  (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
17322
17336
  */
17323
- //# sourceMappingURL=chunk-ZNAFNCPW.js.map
17337
+ //# sourceMappingURL=chunk-HCLEIAGO.js.map