@base44-preview/cli 0.1.32-pr.662.1bdb1fe → 0.1.32-pr.662.e04bb64
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/index.js +35 -19
- package/dist/cli/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -253287,14 +253287,15 @@ var MAX_EDGE_ERRORS = 5;
|
|
|
253287
253287
|
var MAX_INSPECTED_BODY_BYTES = 8192;
|
|
253288
253288
|
var BODY_READ_TIMEOUT_MS = 500;
|
|
253289
253289
|
var PLAIN_TEXT_EDGE_ERROR = /^error code: (\\d{3,4})\\s*$/;
|
|
253290
|
+
var UNBRANDED_5XX_PAGE = /<center>cloudflare<\\/center>/i;
|
|
253290
253291
|
var SAFE_VALUE = /^[\\x20-\\x7e]{1,253}$/;
|
|
253291
253292
|
function safe(value) {
|
|
253292
253293
|
return typeof value === "string" && SAFE_VALUE.test(value) ? value : void 0;
|
|
253293
253294
|
}
|
|
253294
|
-
function parseEdgeErrorBody(body) {
|
|
253295
|
+
function parseEdgeErrorBody(body, status) {
|
|
253295
253296
|
const plain = PLAIN_TEXT_EDGE_ERROR.exec(body);
|
|
253296
253297
|
if (plain) return { code: Number(plain[1]) };
|
|
253297
|
-
if (
|
|
253298
|
+
if (status >= 500 && UNBRANDED_5XX_PAGE.test(body)) return { code: status };
|
|
253298
253299
|
try {
|
|
253299
253300
|
const json = JSON.parse(body);
|
|
253300
253301
|
if (json === null || typeof json !== "object") return null;
|
|
@@ -253310,24 +253311,39 @@ function parseEdgeErrorBody(body) {
|
|
|
253310
253311
|
return null;
|
|
253311
253312
|
}
|
|
253312
253313
|
}
|
|
253313
|
-
async function
|
|
253314
|
-
if (response.
|
|
253315
|
-
const
|
|
253316
|
-
if (!
|
|
253317
|
-
|
|
253318
|
-
}
|
|
253319
|
-
|
|
253314
|
+
async function readBodyPrefix(response) {
|
|
253315
|
+
if (Number(response.headers.get("content-length")) > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253316
|
+
const reader = response.clone().body?.getReader();
|
|
253317
|
+
if (!reader) return "";
|
|
253318
|
+
const timer = setTimeout(() => reader.cancel().catch(() => {
|
|
253319
|
+
}), BODY_READ_TIMEOUT_MS);
|
|
253320
|
+
const decoder = new TextDecoder();
|
|
253321
|
+
let text = "";
|
|
253322
|
+
let size = 0;
|
|
253320
253323
|
try {
|
|
253321
|
-
|
|
253322
|
-
|
|
253323
|
-
|
|
253324
|
-
|
|
253325
|
-
|
|
253326
|
-
|
|
253327
|
-
|
|
253324
|
+
for (; ; ) {
|
|
253325
|
+
const { done, value } = await reader.read();
|
|
253326
|
+
if (done) break;
|
|
253327
|
+
size += value.byteLength;
|
|
253328
|
+
if (size > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253329
|
+
text += decoder.decode(value, { stream: true });
|
|
253330
|
+
}
|
|
253331
|
+
} catch {
|
|
253332
|
+
return null;
|
|
253328
253333
|
} finally {
|
|
253329
253334
|
clearTimeout(timer);
|
|
253335
|
+
reader.cancel().catch(() => {
|
|
253336
|
+
});
|
|
253337
|
+
}
|
|
253338
|
+
return text + decoder.decode();
|
|
253339
|
+
}
|
|
253340
|
+
async function readEdgeError(response) {
|
|
253341
|
+
if (response.status < 400 || !response.headers.get("cf-ray")) return null;
|
|
253342
|
+
if (response.headers.get("cf-mitigated") === "challenge") {
|
|
253343
|
+
return { code: response.status, name: "challenge" };
|
|
253330
253344
|
}
|
|
253345
|
+
const body = await readBodyPrefix(response);
|
|
253346
|
+
return body === null ? null : parseEdgeErrorBody(body, response.status);
|
|
253331
253347
|
}
|
|
253332
253348
|
function targetOrigin(input) {
|
|
253333
253349
|
try {
|
|
@@ -256435,10 +256451,10 @@ var INVOCATION_LOGS_PATCH = [
|
|
|
256435
256451
|
"};",
|
|
256436
256452
|
"const _b44CrashResponse = (e) => {",
|
|
256437
256453
|
" const c = _b44Context();",
|
|
256438
|
-
" if (!c || !
|
|
256454
|
+
" if (!c || !c.invocationLogs) return null;",
|
|
256439
256455
|
" const m = String(e instanceof Error ? e.message : e).toLowerCase();",
|
|
256440
256456
|
" if (m.includes('cpu time limit') || m.includes('too many subrequests')) return null;",
|
|
256441
|
-
" return _b44AttachInvocationLogs(
|
|
256457
|
+
" return _b44AttachInvocationLogs(new Response(JSON.stringify({ error: 'user-exception', detail: 'user worker threw an exception' }), { status: 500, headers: { 'Content-Type': 'application/json' } }));",
|
|
256442
256458
|
"};"
|
|
256443
256459
|
].join(`
|
|
256444
256460
|
`);
|
|
@@ -271519,4 +271535,4 @@ export {
|
|
|
271519
271535
|
runCLI
|
|
271520
271536
|
};
|
|
271521
271537
|
|
|
271522
|
-
//# debugId=
|
|
271538
|
+
//# debugId=45318CD4F94D8EF364756E2164756E21
|