@cnwenf/occ 2.1.313 → 2.1.314
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/cli.js +94 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
globalThis.MACRO={"VERSION":"2.1.
|
|
2
|
+
globalThis.MACRO={"VERSION":"2.1.314","BINARY_NAME":"occ","BUILD_TIME":"2026-08-28T00:45:59.205Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
|
|
3
3
|
// @bun
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -252352,7 +252352,8 @@ var init_TaskOutput = __esm(() => {
|
|
|
252352
252352
|
const tail = safeJoinLines(recent, `
|
|
252353
252353
|
`);
|
|
252354
252354
|
const sizeKB = Math.round(this.#totalBytes / 1024);
|
|
252355
|
-
const notice = `
|
|
252355
|
+
const notice = this.#disk.failing || this.#disk.lostOutput ? `
|
|
252356
|
+
Output truncated (${sizeKB}KB total). The full output could not all be saved to ${this.path}; that file may be missing or incomplete.` : `
|
|
252356
252357
|
Output truncated (${sizeKB}KB total). Full output saved to: ${this.path}`;
|
|
252357
252358
|
return tail ? tail + notice : notice.trimStart();
|
|
252358
252359
|
}
|
|
@@ -726092,6 +726093,7 @@ __export(exports_diskOutput, {
|
|
|
726092
726093
|
appendTaskOutput: () => appendTaskOutput,
|
|
726093
726094
|
_resetTaskOutputDirForTest: () => _resetTaskOutputDirForTest,
|
|
726094
726095
|
_clearOutputsForTest: () => _clearOutputsForTest,
|
|
726096
|
+
OUTPUT_OMITTED_MARKER_FOR_TEST: () => OUTPUT_OMITTED_MARKER_FOR_TEST,
|
|
726095
726097
|
MAX_TASK_OUTPUT_BYTES_DISPLAY: () => MAX_TASK_OUTPUT_BYTES_DISPLAY,
|
|
726096
726098
|
MAX_TASK_OUTPUT_BYTES: () => MAX_TASK_OUTPUT_BYTES,
|
|
726097
726099
|
DiskTaskOutput: () => DiskTaskOutput
|
|
@@ -726132,6 +726134,11 @@ class DiskTaskOutput {
|
|
|
726132
726134
|
#queue = [];
|
|
726133
726135
|
#bytesWritten = 0;
|
|
726134
726136
|
#capped = false;
|
|
726137
|
+
#unwrittenChars = 0;
|
|
726138
|
+
#cancelCount = 0;
|
|
726139
|
+
#failing = false;
|
|
726140
|
+
#seenFailureKeys = new Set;
|
|
726141
|
+
#lostOutput = false;
|
|
726135
726142
|
#flushPromise = null;
|
|
726136
726143
|
#flushResolve = null;
|
|
726137
726144
|
constructor(taskId) {
|
|
@@ -726144,11 +726151,14 @@ class DiskTaskOutput {
|
|
|
726144
726151
|
this.#bytesWritten += content.length;
|
|
726145
726152
|
if (this.#bytesWritten > MAX_TASK_OUTPUT_BYTES) {
|
|
726146
726153
|
this.#capped = true;
|
|
726147
|
-
|
|
726154
|
+
const marker = `
|
|
726148
726155
|
[output truncated: exceeded ${MAX_TASK_OUTPUT_BYTES_DISPLAY} disk cap]
|
|
726149
|
-
|
|
726156
|
+
`;
|
|
726157
|
+
this.#queue.push(marker);
|
|
726158
|
+
this.#unwrittenChars += marker.length;
|
|
726150
726159
|
} else {
|
|
726151
726160
|
this.#queue.push(content);
|
|
726161
|
+
this.#unwrittenChars += content.length;
|
|
726152
726162
|
}
|
|
726153
726163
|
if (!this.#flushPromise) {
|
|
726154
726164
|
this.#flushPromise = new Promise((resolve59) => {
|
|
@@ -726160,8 +726170,19 @@ class DiskTaskOutput {
|
|
|
726160
726170
|
flush() {
|
|
726161
726171
|
return this.#flushPromise ?? Promise.resolve();
|
|
726162
726172
|
}
|
|
726173
|
+
get failing() {
|
|
726174
|
+
return this.#failing;
|
|
726175
|
+
}
|
|
726176
|
+
get lostOutput() {
|
|
726177
|
+
return this.#lostOutput;
|
|
726178
|
+
}
|
|
726179
|
+
get unwrittenChars() {
|
|
726180
|
+
return this.#unwrittenChars;
|
|
726181
|
+
}
|
|
726163
726182
|
cancel() {
|
|
726183
|
+
this.#cancelCount += 1;
|
|
726164
726184
|
this.#queue.length = 0;
|
|
726185
|
+
this.#unwrittenChars = 0;
|
|
726165
726186
|
}
|
|
726166
726187
|
async#drainAllChunks() {
|
|
726167
726188
|
while (true) {
|
|
@@ -726171,7 +726192,17 @@ class DiskTaskOutput {
|
|
|
726171
726192
|
this.#fileHandle = await open15(this.#path, process.platform === "win32" ? "a" : fsConstants9.O_WRONLY | fsConstants9.O_APPEND | fsConstants9.O_CREAT | O_NOFOLLOW2);
|
|
726172
726193
|
}
|
|
726173
726194
|
while (true) {
|
|
726174
|
-
|
|
726195
|
+
const cancelCount = this.#cancelCount;
|
|
726196
|
+
try {
|
|
726197
|
+
await this.#writeAllChunks();
|
|
726198
|
+
} catch (e4) {
|
|
726199
|
+
if (this.#cancelCount === cancelCount) {
|
|
726200
|
+
this.#lostOutput = true;
|
|
726201
|
+
this.#queue.unshift(OUTPUT_OMITTED_MARKER);
|
|
726202
|
+
this.#unwrittenChars += OUTPUT_OMITTED_MARKER.length;
|
|
726203
|
+
}
|
|
726204
|
+
throw e4;
|
|
726205
|
+
}
|
|
726175
726206
|
if (this.#queue.length === 0) {
|
|
726176
726207
|
break;
|
|
726177
726208
|
}
|
|
@@ -726194,6 +726225,7 @@ class DiskTaskOutput {
|
|
|
726194
726225
|
}
|
|
726195
726226
|
#queueToBuffers() {
|
|
726196
726227
|
const queue2 = this.#queue.splice(0, this.#queue.length);
|
|
726228
|
+
this.#unwrittenChars = 0;
|
|
726197
726229
|
let totalLength = 0;
|
|
726198
726230
|
for (const str2 of queue2) {
|
|
726199
726231
|
totalLength += Buffer.byteLength(str2, "utf8");
|
|
@@ -726208,13 +726240,18 @@ class DiskTaskOutput {
|
|
|
726208
726240
|
async#drain() {
|
|
726209
726241
|
try {
|
|
726210
726242
|
await this.#drainAllChunks();
|
|
726243
|
+
this.#clearFailureState();
|
|
726211
726244
|
} catch (e4) {
|
|
726212
|
-
|
|
726245
|
+
if (!this.#failing) {
|
|
726246
|
+
this.#failing = true;
|
|
726247
|
+
logError2(new Error(`Task output drain failed (will retry once): ${e4}`));
|
|
726248
|
+
}
|
|
726213
726249
|
if (this.#queue.length > 0) {
|
|
726214
726250
|
try {
|
|
726215
726251
|
await this.#drainAllChunks();
|
|
726252
|
+
this.#clearFailureState();
|
|
726216
726253
|
} catch (e22) {
|
|
726217
|
-
|
|
726254
|
+
this.#handleFinalDrainFailure(e22);
|
|
726218
726255
|
}
|
|
726219
726256
|
}
|
|
726220
726257
|
} finally {
|
|
@@ -726224,6 +726261,30 @@ class DiskTaskOutput {
|
|
|
726224
726261
|
resolve59();
|
|
726225
726262
|
}
|
|
726226
726263
|
}
|
|
726264
|
+
#clearFailureState() {
|
|
726265
|
+
this.#failing = false;
|
|
726266
|
+
this.#seenFailureKeys.clear();
|
|
726267
|
+
}
|
|
726268
|
+
#handleFinalDrainFailure(e4) {
|
|
726269
|
+
const code = getErrnoCode(e4);
|
|
726270
|
+
const kind = code !== undefined && DISK_EXHAUSTION_ERRNOS.has(code) ? "exhaustion" : "unexpected";
|
|
726271
|
+
const failureKey = `${kind}:${code ?? "no errno"}`;
|
|
726272
|
+
if (!this.#seenFailureKeys.has(failureKey)) {
|
|
726273
|
+
this.#seenFailureKeys.add(failureKey);
|
|
726274
|
+
if (kind === "exhaustion") {
|
|
726275
|
+
logError2(new Error(`Task output drain retry failed (${code}): ${e4}`));
|
|
726276
|
+
} else {
|
|
726277
|
+
logError2(e4);
|
|
726278
|
+
}
|
|
726279
|
+
}
|
|
726280
|
+
if (this.#unwrittenChars > MAX_UNWRITTEN_CHARS_BEFORE_DROP) {
|
|
726281
|
+
logError2(new Error(`Task output still cannot be written (${code ?? "no errno"}); dropped ${this.#unwrittenChars} chars of unwritten output`));
|
|
726282
|
+
this.#lostOutput = true;
|
|
726283
|
+
this.#queue.length = 0;
|
|
726284
|
+
this.#queue.push(OUTPUT_OMITTED_MARKER);
|
|
726285
|
+
this.#unwrittenChars = OUTPUT_OMITTED_MARKER.length;
|
|
726286
|
+
}
|
|
726287
|
+
}
|
|
726227
726288
|
}
|
|
726228
726289
|
async function _clearOutputsForTest() {
|
|
726229
726290
|
for (const output2 of outputs.values()) {
|
|
@@ -726242,6 +726303,14 @@ function getOrCreateOutput(taskId) {
|
|
|
726242
726303
|
}
|
|
726243
726304
|
return output2;
|
|
726244
726305
|
}
|
|
726306
|
+
function logTaskOutputFailure(context8, e4) {
|
|
726307
|
+
const code = getErrnoCode(e4);
|
|
726308
|
+
if (code && DISK_EXHAUSTION_ERRNOS.has(code)) {
|
|
726309
|
+
logError2(new Error(`${context8} failed (${code}): ${e4}`));
|
|
726310
|
+
} else {
|
|
726311
|
+
logError2(e4);
|
|
726312
|
+
}
|
|
726313
|
+
}
|
|
726245
726314
|
function appendTaskOutput(taskId, content) {
|
|
726246
726315
|
getOrCreateOutput(taskId).append(content);
|
|
726247
726316
|
}
|
|
@@ -726256,6 +726325,9 @@ function evictTaskOutput(taskId) {
|
|
|
726256
726325
|
const output2 = outputs.get(taskId);
|
|
726257
726326
|
if (output2) {
|
|
726258
726327
|
await output2.flush();
|
|
726328
|
+
if (output2.failing && output2.unwrittenChars > 0) {
|
|
726329
|
+
logError2(new Error(`Task output writer evicted while failing; discarded ${output2.unwrittenChars} chars of unwritten output`));
|
|
726330
|
+
}
|
|
726259
726331
|
outputs.delete(taskId);
|
|
726260
726332
|
}
|
|
726261
726333
|
})());
|
|
@@ -726275,7 +726347,7 @@ async function getTaskOutputDelta(taskId, fromOffset, maxBytes = DEFAULT_MAX_REA
|
|
|
726275
726347
|
if (code === "ENOENT") {
|
|
726276
726348
|
return { content: "", newOffset: fromOffset };
|
|
726277
726349
|
}
|
|
726278
|
-
|
|
726350
|
+
logTaskOutputFailure("getTaskOutputDelta", e4);
|
|
726279
726351
|
return { content: "", newOffset: fromOffset };
|
|
726280
726352
|
}
|
|
726281
726353
|
}
|
|
@@ -726292,7 +726364,7 @@ ${content}`;
|
|
|
726292
726364
|
if (code === "ENOENT") {
|
|
726293
726365
|
return "";
|
|
726294
726366
|
}
|
|
726295
|
-
|
|
726367
|
+
logTaskOutputFailure("getTaskOutput", e4);
|
|
726296
726368
|
return "";
|
|
726297
726369
|
}
|
|
726298
726370
|
}
|
|
@@ -726304,7 +726376,7 @@ async function getTaskOutputSize(taskId) {
|
|
|
726304
726376
|
if (code === "ENOENT") {
|
|
726305
726377
|
return 0;
|
|
726306
726378
|
}
|
|
726307
|
-
|
|
726379
|
+
logTaskOutputFailure("getTaskOutputSize", e4);
|
|
726308
726380
|
return 0;
|
|
726309
726381
|
}
|
|
726310
726382
|
}
|
|
@@ -726321,7 +726393,7 @@ async function cleanupTaskOutput(taskId) {
|
|
|
726321
726393
|
if (code === "ENOENT") {
|
|
726322
726394
|
return;
|
|
726323
726395
|
}
|
|
726324
|
-
|
|
726396
|
+
logTaskOutputFailure("cleanupTaskOutput", e4);
|
|
726325
726397
|
}
|
|
726326
726398
|
}
|
|
726327
726399
|
function initTaskOutput(taskId) {
|
|
@@ -726351,7 +726423,9 @@ function initTaskOutputAsSymlink(taskId, targetPath) {
|
|
|
726351
726423
|
}
|
|
726352
726424
|
})());
|
|
726353
726425
|
}
|
|
726354
|
-
var O_NOFOLLOW2, DEFAULT_MAX_READ_BYTES, MAX_TASK_OUTPUT_BYTES, MAX_TASK_OUTPUT_BYTES_DISPLAY = "5GB",
|
|
726426
|
+
var O_NOFOLLOW2, DEFAULT_MAX_READ_BYTES, MAX_TASK_OUTPUT_BYTES, MAX_TASK_OUTPUT_BYTES_DISPLAY = "5GB", MAX_UNWRITTEN_CHARS_BEFORE_DROP, OUTPUT_OMITTED_MARKER = `
|
|
726427
|
+
[output omitted: it could not be written to disk]
|
|
726428
|
+
`, OUTPUT_OMITTED_MARKER_FOR_TEST, DISK_EXHAUSTION_ERRNOS, _taskOutputDir, _pendingOps, outputs;
|
|
726355
726429
|
var init_diskOutput = __esm(() => {
|
|
726356
726430
|
init_state();
|
|
726357
726431
|
init_errors();
|
|
@@ -726361,6 +726435,14 @@ var init_diskOutput = __esm(() => {
|
|
|
726361
726435
|
O_NOFOLLOW2 = fsConstants9.O_NOFOLLOW ?? 0;
|
|
726362
726436
|
DEFAULT_MAX_READ_BYTES = 8 * 1024 * 1024;
|
|
726363
726437
|
MAX_TASK_OUTPUT_BYTES = 5 * 1024 * 1024 * 1024;
|
|
726438
|
+
MAX_UNWRITTEN_CHARS_BEFORE_DROP = 16 * 1024 * 1024;
|
|
726439
|
+
OUTPUT_OMITTED_MARKER_FOR_TEST = OUTPUT_OMITTED_MARKER;
|
|
726440
|
+
DISK_EXHAUSTION_ERRNOS = new Set([
|
|
726441
|
+
"ENOSPC",
|
|
726442
|
+
"EDQUOT",
|
|
726443
|
+
"ENFILE",
|
|
726444
|
+
"EMFILE"
|
|
726445
|
+
]);
|
|
726364
726446
|
_pendingOps = new Set;
|
|
726365
726447
|
outputs = new Map;
|
|
726366
726448
|
});
|