@validate.qa/runner 1.0.96 → 1.0.98
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/dist/{chunk-2BYRCDXC.mjs → chunk-J4ST6MFT.mjs} +196 -64
- package/dist/cli.js +3288 -723
- package/dist/cli.mjs +3095 -662
- package/dist/tar-extract-child.js +251 -104
- package/dist/tar-extract-child.mjs +41 -26
- package/package.json +6 -5
|
@@ -9220,7 +9220,6 @@ var require_repo_acquire = __commonJS({
|
|
|
9220
9220
|
var MAX_TAR_BYTES_AFTER_END = 1024 * 1024;
|
|
9221
9221
|
var TAR_OVERHEAD_PER_ENTRY = 4096;
|
|
9222
9222
|
var TAR_OVERHEAD_BASE = 16 * 1024 * 1024;
|
|
9223
|
-
var TAR_COUNTED_TYPES = /* @__PURE__ */ new Set(["File", "OldFile", "ContiguousFile", "Directory", "GNUDumpDir"]);
|
|
9224
9223
|
function refuseNestedGzip() {
|
|
9225
9224
|
let head = Buffer.alloc(0);
|
|
9226
9225
|
return new node_stream_1.Transform({
|
|
@@ -9284,7 +9283,7 @@ var require_repo_acquire = __commonJS({
|
|
|
9284
9283
|
bad = new Error(`Tar entry too large: ${shownPath} (declared ${size} bytes > ${limits.maxFileBytes} cap)`);
|
|
9285
9284
|
} else if ((declaredTotal += size) > limits.maxTotalBytes) {
|
|
9286
9285
|
bad = new Error(`Tar total uncompressed size exceeds ${limits.maxTotalBytes} cap (tar-bomb guard)`);
|
|
9287
|
-
} else if (
|
|
9286
|
+
} else if (++entries > limits.maxEntries) {
|
|
9288
9287
|
bad = new Error(`Tar has too many entries: > ${limits.maxEntries} cap`);
|
|
9289
9288
|
}
|
|
9290
9289
|
if (bad)
|
|
@@ -9430,11 +9429,22 @@ var require_tar_isolated = __commonJS({
|
|
|
9430
9429
|
"../runner-core/dist/services/tar-isolated.js"(exports) {
|
|
9431
9430
|
"use strict";
|
|
9432
9431
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9433
|
-
exports.TAR_ISOLATED_MAX_CHILDREN_PER_TENANT = exports.TAR_ISOLATED_MAX_CHILDREN = exports.TarIsolationError = exports.TarIsolationUnavailableError = exports.TAR_ISOLATION_UNAVAILABLE_MESSAGE = exports.TAR_CHILD_MARKER_ENV = exports.TAR_ISOLATED_MAX_OLD_SPACE_MB = exports.TAR_ISOLATED_TIMEOUT_MS = void 0;
|
|
9432
|
+
exports.IsolationSlots = exports.SlotPool = exports.ISOLATED_MIN_CHILD_HEAP_MB = exports.ISOLATED_MEMORY_MARGIN_MB = exports.TAR_ISOLATED_MAX_CHILDREN_PER_TENANT = exports.TAR_ISOLATED_MAX_CHILDREN = exports.ISOLATED_MAX_CHILDREN = exports.TarIsolationError = exports.TarIsolationUnavailableError = exports.TAR_ISOLATION_UNAVAILABLE_MESSAGE = exports.TAR_CHILD_MARKER_ENV = exports.TAR_ISOLATED_MAX_OLD_SPACE_MB = exports.TAR_ISOLATED_TIMEOUT_MS = void 0;
|
|
9433
|
+
exports.isolatedChildEnv = isolatedChildEnv;
|
|
9434
9434
|
exports.tarChildEnv = tarChildEnv;
|
|
9435
|
+
exports.resolveIsolatedChildEntry = resolveIsolatedChildEntry;
|
|
9435
9436
|
exports.resolveTarChildEntry = resolveTarChildEntry;
|
|
9437
|
+
exports.deriveIsolatedChildBudget = deriveIsolatedChildBudget;
|
|
9438
|
+
exports.deriveMaxIsolatedChildren = deriveMaxIsolatedChildren;
|
|
9439
|
+
exports.effectiveChildHeapMb = effectiveChildHeapMb;
|
|
9440
|
+
exports.envHeapCap = envHeapCap;
|
|
9441
|
+
exports.readMemoryLimitBytes = readMemoryLimitBytes;
|
|
9442
|
+
exports.isolatedChildBudget = isolatedChildBudget;
|
|
9443
|
+
exports.maxIsolatedChildren = maxIsolatedChildren;
|
|
9436
9444
|
exports.tarIsolationLoad = tarIsolationLoad;
|
|
9445
|
+
exports.isolationLoad = isolationLoad;
|
|
9437
9446
|
exports.runTarJobIsolated = runTarJobIsolated;
|
|
9447
|
+
exports.runIsolatedJob = runIsolatedJob;
|
|
9438
9448
|
exports.extractTarGzIsolated = extractTarGzIsolated;
|
|
9439
9449
|
exports.extractZipIsolated = extractZipIsolated;
|
|
9440
9450
|
exports.slimRepoArchiveIsolated = slimRepoArchiveIsolated;
|
|
@@ -9442,8 +9452,10 @@ var require_tar_isolated = __commonJS({
|
|
|
9442
9452
|
var node_child_process_1 = __require("child_process");
|
|
9443
9453
|
var node_fs_1 = __require("fs");
|
|
9444
9454
|
var promises_1 = __require("fs/promises");
|
|
9455
|
+
var node_os_1 = __require("os");
|
|
9445
9456
|
var node_path_1 = __require("path");
|
|
9446
9457
|
var node_url_1 = __require("url");
|
|
9458
|
+
var node_v8_1 = __require("v8");
|
|
9447
9459
|
var repo_acquire_js_1 = require_repo_acquire();
|
|
9448
9460
|
exports.TAR_ISOLATED_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
9449
9461
|
exports.TAR_ISOLATED_MAX_OLD_SPACE_MB = 512;
|
|
@@ -9472,23 +9484,26 @@ var require_tar_isolated = __commonJS({
|
|
|
9472
9484
|
const n = Number(process.env[name]);
|
|
9473
9485
|
return Number.isSafeInteger(n) && n > 0 ? n : fallback;
|
|
9474
9486
|
}
|
|
9475
|
-
function
|
|
9487
|
+
function isolatedChildEnv(markerEnv, source = process.env) {
|
|
9476
9488
|
const env = {};
|
|
9477
9489
|
for (const key of CHILD_ENV_ALLOWLIST) {
|
|
9478
9490
|
const value = source[key];
|
|
9479
9491
|
if (typeof value === "string")
|
|
9480
9492
|
env[key] = value;
|
|
9481
9493
|
}
|
|
9482
|
-
env[
|
|
9494
|
+
env[markerEnv] = "1";
|
|
9483
9495
|
return env;
|
|
9484
9496
|
}
|
|
9485
|
-
function
|
|
9486
|
-
|
|
9497
|
+
function tarChildEnv(source = process.env) {
|
|
9498
|
+
return isolatedChildEnv(exports.TAR_CHILD_MARKER_ENV, source);
|
|
9499
|
+
}
|
|
9500
|
+
function resolveIsolatedChildEntry(dir, basename) {
|
|
9501
|
+
if (typeof dir !== "string")
|
|
9487
9502
|
return null;
|
|
9488
|
-
const js = (0, node_path_1.join)(
|
|
9503
|
+
const js = (0, node_path_1.join)(dir, `${basename}.js`);
|
|
9489
9504
|
if ((0, node_fs_1.existsSync)(js))
|
|
9490
9505
|
return { file: js, execArgv: [] };
|
|
9491
|
-
const ts = (0, node_path_1.join)(
|
|
9506
|
+
const ts = (0, node_path_1.join)(dir, `${basename}.ts`);
|
|
9492
9507
|
if (!(0, node_fs_1.existsSync)(ts))
|
|
9493
9508
|
return null;
|
|
9494
9509
|
try {
|
|
@@ -9497,10 +9512,76 @@ var require_tar_isolated = __commonJS({
|
|
|
9497
9512
|
return null;
|
|
9498
9513
|
}
|
|
9499
9514
|
}
|
|
9500
|
-
|
|
9515
|
+
function resolveTarChildEntry() {
|
|
9516
|
+
return resolveIsolatedChildEntry(typeof __dirname === "string" ? __dirname : void 0, CHILD_BASENAME);
|
|
9517
|
+
}
|
|
9518
|
+
exports.ISOLATED_MAX_CHILDREN = 2;
|
|
9519
|
+
exports.TAR_ISOLATED_MAX_CHILDREN = exports.ISOLATED_MAX_CHILDREN;
|
|
9501
9520
|
exports.TAR_ISOLATED_MAX_CHILDREN_PER_TENANT = 1;
|
|
9502
|
-
|
|
9503
|
-
|
|
9521
|
+
exports.ISOLATED_MEMORY_MARGIN_MB = 256;
|
|
9522
|
+
exports.ISOLATED_MIN_CHILD_HEAP_MB = 256;
|
|
9523
|
+
var MB = 1024 * 1024;
|
|
9524
|
+
function deriveIsolatedChildBudget(input) {
|
|
9525
|
+
const freeMb = (input.memoryLimitBytes - input.heapLimitBytes) / MB - (input.marginMb ?? exports.ISOLATED_MEMORY_MARGIN_MB);
|
|
9526
|
+
const fit = Math.floor(freeMb / Math.max(1, input.childHeapMb));
|
|
9527
|
+
if (Number.isFinite(fit) && fit >= 1)
|
|
9528
|
+
return { children: Math.min(exports.ISOLATED_MAX_CHILDREN, fit), heapLimitMb: null };
|
|
9529
|
+
return { children: 1, heapLimitMb: Math.max(exports.ISOLATED_MIN_CHILD_HEAP_MB, Number.isFinite(freeMb) ? Math.floor(freeMb) : 0) };
|
|
9530
|
+
}
|
|
9531
|
+
function deriveMaxIsolatedChildren(input) {
|
|
9532
|
+
return deriveIsolatedChildBudget(input).children;
|
|
9533
|
+
}
|
|
9534
|
+
function effectiveChildHeapMb(cap, budget) {
|
|
9535
|
+
if (cap.fromEnv || budget.heapLimitMb === null)
|
|
9536
|
+
return cap.mb;
|
|
9537
|
+
return Math.min(cap.mb, budget.heapLimitMb);
|
|
9538
|
+
}
|
|
9539
|
+
function envHeapCap(name, fallback) {
|
|
9540
|
+
const n = Number(process.env[name]);
|
|
9541
|
+
return Number.isSafeInteger(n) && n > 0 ? { mb: n, fromEnv: true } : { mb: fallback, fromEnv: false };
|
|
9542
|
+
}
|
|
9543
|
+
function readMemoryLimitBytes(read = (path) => (0, node_fs_1.readFileSync)(path, "utf8"), total = node_os_1.totalmem) {
|
|
9544
|
+
try {
|
|
9545
|
+
const raw = read("/sys/fs/cgroup/memory.max").trim();
|
|
9546
|
+
const limit = Number(raw);
|
|
9547
|
+
if (raw !== "max" && Number.isSafeInteger(limit) && limit > 0)
|
|
9548
|
+
return Math.min(limit, total());
|
|
9549
|
+
} catch {
|
|
9550
|
+
}
|
|
9551
|
+
return total();
|
|
9552
|
+
}
|
|
9553
|
+
var memoryLimitCache;
|
|
9554
|
+
var childHeapCaps = /* @__PURE__ */ new Set();
|
|
9555
|
+
function isolatedChildBudget() {
|
|
9556
|
+
const override = Number(process.env.ISOLATED_CHILDREN_MAX ?? process.env.REPO_ARCHIVE_EXTRACT_MAX_CHILDREN);
|
|
9557
|
+
if (Number.isSafeInteger(override) && override > 0)
|
|
9558
|
+
return { children: override, heapLimitMb: null };
|
|
9559
|
+
memoryLimitCache ??= readMemoryLimitBytes();
|
|
9560
|
+
let childHeapMb = 0;
|
|
9561
|
+
for (const cap of childHeapCaps)
|
|
9562
|
+
childHeapMb = Math.max(childHeapMb, cap().mb);
|
|
9563
|
+
return deriveIsolatedChildBudget({
|
|
9564
|
+
memoryLimitBytes: memoryLimitCache,
|
|
9565
|
+
heapLimitBytes: (0, node_v8_1.getHeapStatistics)().heap_size_limit,
|
|
9566
|
+
childHeapMb: childHeapMb || exports.TAR_ISOLATED_MAX_OLD_SPACE_MB
|
|
9567
|
+
});
|
|
9568
|
+
}
|
|
9569
|
+
function maxIsolatedChildren() {
|
|
9570
|
+
return isolatedChildBudget().children;
|
|
9571
|
+
}
|
|
9572
|
+
var heapReductionLogged = false;
|
|
9573
|
+
function childHeapMbFor(slots, log) {
|
|
9574
|
+
const cap = slots.heapCap();
|
|
9575
|
+
const budget = isolatedChildBudget();
|
|
9576
|
+
const mb = effectiveChildHeapMb(cap, budget);
|
|
9577
|
+
if (mb < cap.mb && !heapReductionLogged) {
|
|
9578
|
+
heapReductionLogged = true;
|
|
9579
|
+
const floored = budget.heapLimitMb === exports.ISOLATED_MIN_CHILD_HEAP_MB ? ` (the ${exports.ISOLATED_MIN_CHILD_HEAP_MB} MB floor: the ${exports.ISOLATED_MEMORY_MARGIN_MB} MB margin is not fully kept)` : "";
|
|
9580
|
+
const line = `[isolated-child] isolated child heap reduced to ${mb} MB to fit memory${floored}; set ISOLATED_CHILDREN_MAX or the kind's heap env knob to override`;
|
|
9581
|
+
console.warn(line);
|
|
9582
|
+
log?.(line);
|
|
9583
|
+
}
|
|
9584
|
+
return mb;
|
|
9504
9585
|
}
|
|
9505
9586
|
var SlotPool = class {
|
|
9506
9587
|
capacity;
|
|
@@ -9542,31 +9623,59 @@ var require_tar_isolated = __commonJS({
|
|
|
9542
9623
|
this.inUse -= 1;
|
|
9543
9624
|
}
|
|
9544
9625
|
};
|
|
9545
|
-
|
|
9546
|
-
var
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9626
|
+
exports.SlotPool = SlotPool;
|
|
9627
|
+
var processSlots = new SlotPool(maxIsolatedChildren);
|
|
9628
|
+
var IsolationSlots = class {
|
|
9629
|
+
perTenant;
|
|
9630
|
+
heapCap;
|
|
9631
|
+
global = processSlots;
|
|
9632
|
+
/** Per-tenant pools, created on demand and dropped when idle. */
|
|
9633
|
+
tenants = /* @__PURE__ */ new Map();
|
|
9634
|
+
/** This kind's children still running. */
|
|
9635
|
+
live = /* @__PURE__ */ new Set();
|
|
9636
|
+
constructor(perTenant, heapCap) {
|
|
9637
|
+
this.perTenant = perTenant;
|
|
9638
|
+
this.heapCap = heapCap;
|
|
9639
|
+
childHeapCaps.add(heapCap);
|
|
9640
|
+
}
|
|
9641
|
+
tenantPool(key) {
|
|
9642
|
+
let pool = this.tenants.get(key);
|
|
9643
|
+
if (!pool) {
|
|
9644
|
+
pool = new SlotPool(() => this.perTenant);
|
|
9645
|
+
this.tenants.set(key, pool);
|
|
9646
|
+
}
|
|
9647
|
+
return pool;
|
|
9648
|
+
}
|
|
9649
|
+
/** Drop an idle tenant pool (after a release, or a wait that gave up). */
|
|
9650
|
+
forgetIfIdle(key, pool) {
|
|
9651
|
+
if (pool.inUse === 0 && pool.queued === 0 && this.tenants.get(key) === pool)
|
|
9652
|
+
this.tenants.delete(key);
|
|
9653
|
+
}
|
|
9654
|
+
releaseTenant(key, pool) {
|
|
9655
|
+
pool.release();
|
|
9656
|
+
this.forgetIfIdle(key, pool);
|
|
9657
|
+
}
|
|
9658
|
+
/** This kind's live children, process-wide slots held and waiting, and this kind's jobs waiting behind their own tenant. */
|
|
9659
|
+
load() {
|
|
9660
|
+
let tenantQueued = 0;
|
|
9661
|
+
for (const pool of this.tenants.values())
|
|
9662
|
+
tenantQueued += pool.queued;
|
|
9663
|
+
return { children: this.live.size, slots: this.global.inUse, queued: this.global.queued, tenantQueued };
|
|
9664
|
+
}
|
|
9665
|
+
};
|
|
9666
|
+
exports.IsolationSlots = IsolationSlots;
|
|
9667
|
+
var tarSlots = new IsolationSlots(exports.TAR_ISOLATED_MAX_CHILDREN_PER_TENANT, () => envHeapCap("REPO_ARCHIVE_EXTRACT_MAX_OLD_SPACE_MB", exports.TAR_ISOLATED_MAX_OLD_SPACE_MB));
|
|
9560
9668
|
function tarIsolationLoad() {
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
return { children: liveChildren.size, slots:
|
|
9669
|
+
return tarSlots.load();
|
|
9670
|
+
}
|
|
9671
|
+
function isolationLoad() {
|
|
9672
|
+
return { children: liveChildren.size, slots: processSlots.inUse, queued: processSlots.queued };
|
|
9565
9673
|
}
|
|
9566
9674
|
var liveChildren = /* @__PURE__ */ new Set();
|
|
9567
9675
|
var exitHookInstalled = false;
|
|
9568
|
-
function trackChild(child) {
|
|
9676
|
+
function trackChild(child, slots) {
|
|
9569
9677
|
liveChildren.add(child);
|
|
9678
|
+
slots.live.add(child);
|
|
9570
9679
|
if (exitHookInstalled)
|
|
9571
9680
|
return;
|
|
9572
9681
|
exitHookInstalled = true;
|
|
@@ -9575,6 +9684,23 @@ var require_tar_isolated = __commonJS({
|
|
|
9575
9684
|
c.kill("SIGKILL");
|
|
9576
9685
|
});
|
|
9577
9686
|
}
|
|
9687
|
+
function untrackChild(child, slots) {
|
|
9688
|
+
liveChildren.delete(child);
|
|
9689
|
+
slots.live.delete(child);
|
|
9690
|
+
}
|
|
9691
|
+
var TAR_CHILD_SPEC = {
|
|
9692
|
+
name: CHILD_BASENAME,
|
|
9693
|
+
dir: typeof __dirname === "string" ? __dirname : void 0,
|
|
9694
|
+
resolveEntry: resolveTarChildEntry,
|
|
9695
|
+
markerEnv: exports.TAR_CHILD_MARKER_ENV,
|
|
9696
|
+
slots: tarSlots,
|
|
9697
|
+
defaultTimeoutMs: () => positiveIntEnv("REPO_ARCHIVE_EXTRACT_TIMEOUT_MS", exports.TAR_ISOLATED_TIMEOUT_MS),
|
|
9698
|
+
failureMessage: (subject, detail) => `CONFIG_ISSUE: The ${subject} couldn't be unpacked (${detail}).`,
|
|
9699
|
+
workerName: "archive extractor",
|
|
9700
|
+
childName: "extractor",
|
|
9701
|
+
jobName: "extraction",
|
|
9702
|
+
logPrefix: "[tar-isolated]"
|
|
9703
|
+
};
|
|
9578
9704
|
function jobCwd(job) {
|
|
9579
9705
|
switch (job.op) {
|
|
9580
9706
|
case "extract":
|
|
@@ -9588,58 +9714,64 @@ var require_tar_isolated = __commonJS({
|
|
|
9588
9714
|
}
|
|
9589
9715
|
}
|
|
9590
9716
|
function runTarJobIsolated(job, subject, options = {}) {
|
|
9591
|
-
return runJob(job, subject, options, true);
|
|
9717
|
+
return runJob(TAR_CHILD_SPEC, job, subject, { ...options, cwd: jobCwd(job) }, true);
|
|
9718
|
+
}
|
|
9719
|
+
function runIsolatedJob(spec, job, subject, options = {}) {
|
|
9720
|
+
return runJob(spec, job, subject, options, true);
|
|
9592
9721
|
}
|
|
9593
|
-
async function runJob(job, subject, options, limited) {
|
|
9594
|
-
const entry = options.testChildFile === void 0 ?
|
|
9722
|
+
async function runJob(spec, job, subject, options, limited) {
|
|
9723
|
+
const entry = options.testChildFile === void 0 ? spec.resolveEntry() : options.testChildFile && (0, node_fs_1.existsSync)(options.testChildFile) ? { file: options.testChildFile, execArgv: [] } : null;
|
|
9595
9724
|
if (!entry)
|
|
9596
|
-
throw new TarIsolationUnavailableError(`${
|
|
9597
|
-
const
|
|
9725
|
+
throw new TarIsolationUnavailableError(`${spec.name}.js was not found beside ${spec.dir ?? "this module"}`);
|
|
9726
|
+
const jobTitle = spec.jobName.charAt(0).toUpperCase() + spec.jobName.slice(1);
|
|
9727
|
+
const abortError = () => Object.assign(new Error(`${jobTitle} of the ${subject} was stopped`), { name: "AbortError" });
|
|
9598
9728
|
if (options.signal?.aborted)
|
|
9599
9729
|
throw abortError();
|
|
9600
|
-
const timeoutMs = options.timeoutMs ??
|
|
9601
|
-
const maxOldSpaceMb = options.maxOldSpaceMb ??
|
|
9602
|
-
const failure = (reason, detail) => new TarIsolationError(reason,
|
|
9730
|
+
const timeoutMs = options.timeoutMs ?? spec.defaultTimeoutMs();
|
|
9731
|
+
const maxOldSpaceMb = options.maxOldSpaceMb ?? childHeapMbFor(spec.slots, options.log);
|
|
9732
|
+
const failure = (reason, detail) => new TarIsolationError(reason, `${spec.failureMessage(subject, detail)}${options.hint ? ` ${options.hint}` : ""}`);
|
|
9603
9733
|
if (!limited)
|
|
9604
|
-
return runChild(job, entry, timeoutMs, maxOldSpaceMb, options, failure, abortError);
|
|
9605
|
-
const
|
|
9734
|
+
return runChild(spec, job, entry, timeoutMs, maxOldSpaceMb, options, failure, abortError);
|
|
9735
|
+
const queueMs = options.queueTimeoutMs ?? timeoutMs;
|
|
9736
|
+
const deadline = Date.now() + queueMs;
|
|
9606
9737
|
const queueTimeout = () => {
|
|
9607
|
-
const
|
|
9608
|
-
|
|
9738
|
+
const detail = `no ${spec.workerName} was free within ${Math.round(queueMs / 1e3)} s`;
|
|
9739
|
+
const err = spec.busyMessage ? new TarIsolationError("timeout", spec.busyMessage(subject, detail)) : failure("timeout", detail);
|
|
9740
|
+
options.log?.(`${spec.logPrefix} ${err.message}`);
|
|
9609
9741
|
return err;
|
|
9610
9742
|
};
|
|
9611
|
-
const
|
|
9743
|
+
const { slots } = spec;
|
|
9744
|
+
const tenant = options.tenantKey ? { key: options.tenantKey, pool: slots.tenantPool(options.tenantKey) } : null;
|
|
9612
9745
|
if (tenant) {
|
|
9613
|
-
const got = await tenant.pool.acquire(
|
|
9746
|
+
const got = await tenant.pool.acquire(queueMs, options.signal);
|
|
9614
9747
|
if (got !== "ok") {
|
|
9615
|
-
|
|
9616
|
-
tenantSlots.delete(tenant.key);
|
|
9748
|
+
slots.forgetIfIdle(tenant.key, tenant.pool);
|
|
9617
9749
|
throw got === "aborted" ? abortError() : queueTimeout();
|
|
9618
9750
|
}
|
|
9619
9751
|
}
|
|
9620
9752
|
let holdsGlobal = false;
|
|
9621
9753
|
try {
|
|
9622
|
-
const got = await
|
|
9754
|
+
const got = await slots.global.acquire(deadline - Date.now(), options.signal);
|
|
9623
9755
|
if (got !== "ok")
|
|
9624
9756
|
throw got === "aborted" ? abortError() : queueTimeout();
|
|
9625
9757
|
holdsGlobal = true;
|
|
9626
9758
|
if (options.signal?.aborted)
|
|
9627
9759
|
throw abortError();
|
|
9628
|
-
return await runChild(job, entry, timeoutMs, maxOldSpaceMb, options, failure, abortError);
|
|
9760
|
+
return await runChild(spec, job, entry, timeoutMs, maxOldSpaceMb, options, failure, abortError);
|
|
9629
9761
|
} finally {
|
|
9630
9762
|
if (holdsGlobal)
|
|
9631
|
-
|
|
9763
|
+
slots.global.release();
|
|
9632
9764
|
if (tenant)
|
|
9633
|
-
releaseTenant(tenant.key, tenant.pool);
|
|
9765
|
+
slots.releaseTenant(tenant.key, tenant.pool);
|
|
9634
9766
|
}
|
|
9635
9767
|
}
|
|
9636
|
-
function runChild(job, entry, timeoutMs, maxOldSpaceMb, options, failure, abortError) {
|
|
9768
|
+
function runChild(spec, job, entry, timeoutMs, maxOldSpaceMb, options, failure, abortError) {
|
|
9637
9769
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
9638
9770
|
let child;
|
|
9639
9771
|
try {
|
|
9640
9772
|
child = (0, node_child_process_1.spawn)(process.execPath, [...entry.execArgv, `--max-old-space-size=${maxOldSpaceMb}`, entry.file], {
|
|
9641
|
-
cwd:
|
|
9642
|
-
env:
|
|
9773
|
+
cwd: options.cwd,
|
|
9774
|
+
env: isolatedChildEnv(spec.markerEnv),
|
|
9643
9775
|
stdio: ["ignore", "ignore", "pipe", "ipc"],
|
|
9644
9776
|
serialization: "json",
|
|
9645
9777
|
windowsHide: true
|
|
@@ -9648,7 +9780,7 @@ var require_tar_isolated = __commonJS({
|
|
|
9648
9780
|
rejectPromise(new TarIsolationUnavailableError(err instanceof Error ? err.message : String(err)));
|
|
9649
9781
|
return;
|
|
9650
9782
|
}
|
|
9651
|
-
trackChild(child);
|
|
9783
|
+
trackChild(child, spec.slots);
|
|
9652
9784
|
let started = false;
|
|
9653
9785
|
let timedOut = false;
|
|
9654
9786
|
let aborted = false;
|
|
@@ -9672,7 +9804,7 @@ var require_tar_isolated = __commonJS({
|
|
|
9672
9804
|
settled = true;
|
|
9673
9805
|
clearTimeout(timer);
|
|
9674
9806
|
options.signal?.removeEventListener("abort", onAbort);
|
|
9675
|
-
|
|
9807
|
+
untrackChild(child, spec.slots);
|
|
9676
9808
|
fn();
|
|
9677
9809
|
};
|
|
9678
9810
|
child.stderr?.setEncoding("utf8");
|
|
@@ -9715,18 +9847,18 @@ var require_tar_isolated = __commonJS({
|
|
|
9715
9847
|
}
|
|
9716
9848
|
const tail = stderr.trim();
|
|
9717
9849
|
if (tail)
|
|
9718
|
-
options.log?.(
|
|
9850
|
+
options.log?.(`${spec.logPrefix} ${spec.childName} stderr: ${tail.replace(/\s+/g, " ").slice(-1e3)}`);
|
|
9719
9851
|
let err;
|
|
9720
9852
|
if (timedOut) {
|
|
9721
|
-
err = failure("timeout",
|
|
9853
|
+
err = failure("timeout", `${spec.jobName} took longer than ${Math.round(timeoutMs / 1e3)} s and was stopped`);
|
|
9722
9854
|
} else if (outOfMemory) {
|
|
9723
|
-
err = failure("oom",
|
|
9855
|
+
err = failure("oom", `${spec.jobName} ran out of memory (${maxOldSpaceMb} MB heap cap)`);
|
|
9724
9856
|
} else if (signal) {
|
|
9725
|
-
err = failure("signal", `the
|
|
9857
|
+
err = failure("signal", `the ${spec.childName} was killed by ${signal}`);
|
|
9726
9858
|
} else {
|
|
9727
|
-
err = failure("crash", `the
|
|
9859
|
+
err = failure("crash", `the ${spec.childName} crashed (exit code ${code ?? "unknown"})`);
|
|
9728
9860
|
}
|
|
9729
|
-
options.log?.(
|
|
9861
|
+
options.log?.(`${spec.logPrefix} ${err.message}`);
|
|
9730
9862
|
rejectPromise(err);
|
|
9731
9863
|
});
|
|
9732
9864
|
});
|
|
@@ -9784,7 +9916,7 @@ var require_tar_isolated = __commonJS({
|
|
|
9784
9916
|
}
|
|
9785
9917
|
async function probeTarIsolation(options = {}) {
|
|
9786
9918
|
try {
|
|
9787
|
-
await runJob({ op: "ping" }, "archive", { timeoutMs: options.timeoutMs ?? 3e4 }, false);
|
|
9919
|
+
await runJob(TAR_CHILD_SPEC, { op: "ping" }, "archive", { timeoutMs: options.timeoutMs ?? 3e4 }, false);
|
|
9788
9920
|
return { ok: true, detail: `archives are extracted in a separate process (${resolveTarChildEntry()?.file ?? "unknown"})` };
|
|
9789
9921
|
} catch (err) {
|
|
9790
9922
|
return { ok: false, detail: err instanceof Error ? err.message : String(err) };
|