@lark-apaas/devtool-kits 1.0.5-alpha.2 → 1.0.5-alpha.3
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/error.html +43 -5
- package/dist/index.cjs +53 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22320,10 +22320,10 @@ var require_layer = __commonJS({
|
|
|
22320
22320
|
var require_methods = __commonJS({
|
|
22321
22321
|
"../../../node_modules/methods/index.js"(exports, module) {
|
|
22322
22322
|
"use strict";
|
|
22323
|
-
var
|
|
22323
|
+
var http2 = __require("http");
|
|
22324
22324
|
module.exports = getCurrentNodeMethods() || getBasicNodeMethods();
|
|
22325
22325
|
function getCurrentNodeMethods() {
|
|
22326
|
-
return
|
|
22326
|
+
return http2.METHODS && http2.METHODS.map(/* @__PURE__ */ __name(function lowerCaseMethod(method) {
|
|
22327
22327
|
return method.toLowerCase();
|
|
22328
22328
|
}, "lowerCaseMethod"));
|
|
22329
22329
|
}
|
|
@@ -26001,7 +26001,7 @@ var require_application = __commonJS({
|
|
|
26001
26001
|
var query = require_query();
|
|
26002
26002
|
var debug = require_src3()("express:application");
|
|
26003
26003
|
var View = require_view();
|
|
26004
|
-
var
|
|
26004
|
+
var http2 = __require("http");
|
|
26005
26005
|
var compileETag = require_utils2().compileETag;
|
|
26006
26006
|
var compileQueryParser = require_utils2().compileQueryParser;
|
|
26007
26007
|
var compileTrust = require_utils2().compileTrust;
|
|
@@ -26250,7 +26250,7 @@ var require_application = __commonJS({
|
|
|
26250
26250
|
tryRender(view, renderOptions, done);
|
|
26251
26251
|
}, "render");
|
|
26252
26252
|
app.listen = /* @__PURE__ */ __name(function listen() {
|
|
26253
|
-
var server =
|
|
26253
|
+
var server = http2.createServer(this);
|
|
26254
26254
|
return server.listen.apply(server, arguments);
|
|
26255
26255
|
}, "listen");
|
|
26256
26256
|
function logerror(err) {
|
|
@@ -26913,12 +26913,12 @@ var require_request = __commonJS({
|
|
|
26913
26913
|
var deprecate = require_depd()("express");
|
|
26914
26914
|
var isIP = __require("net").isIP;
|
|
26915
26915
|
var typeis = require_type_is();
|
|
26916
|
-
var
|
|
26916
|
+
var http2 = __require("http");
|
|
26917
26917
|
var fresh = require_fresh();
|
|
26918
26918
|
var parseRange = require_range_parser();
|
|
26919
26919
|
var parse = require_parseurl();
|
|
26920
26920
|
var proxyaddr = require_proxy_addr();
|
|
26921
|
-
var req = Object.create(
|
|
26921
|
+
var req = Object.create(http2.IncomingMessage.prototype);
|
|
26922
26922
|
module.exports = req;
|
|
26923
26923
|
req.get = req.header = /* @__PURE__ */ __name(function header(name) {
|
|
26924
26924
|
if (!name) {
|
|
@@ -27344,7 +27344,7 @@ var require_response = __commonJS({
|
|
|
27344
27344
|
var deprecate = require_depd()("express");
|
|
27345
27345
|
var encodeUrl = require_encodeurl();
|
|
27346
27346
|
var escapeHtml = require_escape_html();
|
|
27347
|
-
var
|
|
27347
|
+
var http2 = __require("http");
|
|
27348
27348
|
var isAbsolute3 = require_utils2().isAbsolute;
|
|
27349
27349
|
var onFinished = require_on_finished();
|
|
27350
27350
|
var path6 = __require("path");
|
|
@@ -27360,7 +27360,7 @@ var require_response = __commonJS({
|
|
|
27360
27360
|
var mime = send.mime;
|
|
27361
27361
|
var resolve = path6.resolve;
|
|
27362
27362
|
var vary = require_vary();
|
|
27363
|
-
var res = Object.create(
|
|
27363
|
+
var res = Object.create(http2.ServerResponse.prototype);
|
|
27364
27364
|
module.exports = res;
|
|
27365
27365
|
var charsetRegExp = /;\s*charset\s*=/;
|
|
27366
27366
|
res.status = /* @__PURE__ */ __name(function status(code) {
|
|
@@ -28394,7 +28394,8 @@ import fs2 from "fs";
|
|
|
28394
28394
|
import path2 from "path";
|
|
28395
28395
|
import { createReadStream } from "fs";
|
|
28396
28396
|
import { createInterface } from "readline";
|
|
28397
|
-
import
|
|
28397
|
+
import http from "http";
|
|
28398
|
+
import https from "https";
|
|
28398
28399
|
var errorHtmlTemplate = null;
|
|
28399
28400
|
function isConnectionError(err) {
|
|
28400
28401
|
const code = err.code;
|
|
@@ -28408,30 +28409,40 @@ function isConnectionError(err) {
|
|
|
28408
28409
|
return connectionErrorCodes.includes(code || "");
|
|
28409
28410
|
}
|
|
28410
28411
|
__name(isConnectionError, "isConnectionError");
|
|
28411
|
-
function checkServiceAvailable(
|
|
28412
|
+
function checkServiceAvailable(targetUrl, timeout = 1e3) {
|
|
28412
28413
|
return new Promise((resolve) => {
|
|
28413
|
-
|
|
28414
|
-
|
|
28415
|
-
|
|
28416
|
-
|
|
28417
|
-
|
|
28418
|
-
|
|
28419
|
-
|
|
28420
|
-
|
|
28421
|
-
|
|
28422
|
-
|
|
28423
|
-
|
|
28424
|
-
|
|
28425
|
-
|
|
28414
|
+
try {
|
|
28415
|
+
const url = new URL(targetUrl);
|
|
28416
|
+
const isHttps = url.protocol === "https:";
|
|
28417
|
+
const httpModule = isHttps ? https : http;
|
|
28418
|
+
const req = httpModule.request({
|
|
28419
|
+
hostname: url.hostname,
|
|
28420
|
+
port: url.port || (isHttps ? 443 : 80),
|
|
28421
|
+
path: "/",
|
|
28422
|
+
method: "HEAD",
|
|
28423
|
+
timeout
|
|
28424
|
+
}, (res) => {
|
|
28425
|
+
const available = res.statusCode !== 502 && !res.headers["x-proxy-error-page"];
|
|
28426
|
+
resolve(available);
|
|
28427
|
+
});
|
|
28428
|
+
req.on("timeout", () => {
|
|
28429
|
+
req.destroy();
|
|
28430
|
+
resolve(false);
|
|
28431
|
+
});
|
|
28432
|
+
req.on("error", () => {
|
|
28433
|
+
resolve(false);
|
|
28434
|
+
});
|
|
28435
|
+
req.end();
|
|
28436
|
+
} catch (e) {
|
|
28426
28437
|
resolve(false);
|
|
28427
|
-
}
|
|
28438
|
+
}
|
|
28428
28439
|
});
|
|
28429
28440
|
}
|
|
28430
28441
|
__name(checkServiceAvailable, "checkServiceAvailable");
|
|
28431
|
-
async function waitForServiceRecovery(
|
|
28442
|
+
async function waitForServiceRecovery(targetUrl, timeout, interval) {
|
|
28432
28443
|
const startTime = Date.now();
|
|
28433
28444
|
while (Date.now() - startTime < timeout) {
|
|
28434
|
-
const isAvailable = await checkServiceAvailable(
|
|
28445
|
+
const isAvailable = await checkServiceAvailable(targetUrl, 2e3);
|
|
28435
28446
|
if (isAvailable) {
|
|
28436
28447
|
return true;
|
|
28437
28448
|
}
|
|
@@ -28546,32 +28557,32 @@ function handleDevProxyError(err, req, res, options) {
|
|
|
28546
28557
|
const { logs: errorLogs, hasCompileError } = await readRecentErrorLogs(logDir, maxErrorLogs, logFileName);
|
|
28547
28558
|
if (isConnError && !hasCompileError && target) {
|
|
28548
28559
|
console.log("[Proxy Error]: Connection error without compile errors, possibly server restarting...");
|
|
28549
|
-
let targetUrl = null;
|
|
28550
28560
|
try {
|
|
28551
|
-
|
|
28561
|
+
new URL(target);
|
|
28552
28562
|
} catch (e) {
|
|
28553
28563
|
console.error("[Proxy Error]: Invalid target URL:", target);
|
|
28564
|
+
console.log("[Proxy Error]: Showing error page due to invalid target");
|
|
28554
28565
|
}
|
|
28555
|
-
|
|
28556
|
-
|
|
28557
|
-
|
|
28558
|
-
console.log(
|
|
28559
|
-
|
|
28560
|
-
|
|
28561
|
-
console.log("[Proxy Error]: Service recovered, sending redirect");
|
|
28562
|
-
sendSimpleRedirect(req, res);
|
|
28563
|
-
return;
|
|
28564
|
-
}
|
|
28565
|
-
console.log("[Proxy Error]: Service did not recover within timeout, showing error page");
|
|
28566
|
+
console.log(`[Proxy Error]: Waiting for service recovery at ${target} (timeout: ${retryTimeout}ms)...`);
|
|
28567
|
+
const recovered = await waitForServiceRecovery(target, retryTimeout, retryInterval);
|
|
28568
|
+
if (recovered) {
|
|
28569
|
+
console.log("[Proxy Error]: Service recovered within timeout, sending 302 redirect");
|
|
28570
|
+
sendSimpleRedirect(req, res);
|
|
28571
|
+
return;
|
|
28566
28572
|
}
|
|
28567
|
-
console.log("[Proxy Error]:
|
|
28573
|
+
console.log("[Proxy Error]: Service did not recover within timeout, showing error page with probe");
|
|
28574
|
+
}
|
|
28575
|
+
if (isConnError && !hasCompileError) {
|
|
28576
|
+
console.log("[Proxy Error]: Showing error page with auto-refresh probe");
|
|
28577
|
+
} else {
|
|
28578
|
+
console.log("[Proxy Error]: Compile error or non-connection error, showing error page");
|
|
28568
28579
|
}
|
|
28569
|
-
console.log("[Proxy Error]: Compile error or non-connection error, showing error page");
|
|
28570
28580
|
const template = getErrorHtmlTemplate();
|
|
28571
28581
|
const html = injectErrorData(template, errorLogs);
|
|
28572
28582
|
res.writeHead(502, {
|
|
28573
28583
|
"Content-Type": "text/html; charset=utf-8",
|
|
28574
|
-
"Cache-Control": "no-cache, no-store, must-revalidate"
|
|
28584
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
28585
|
+
"X-Proxy-Error-Page": "true"
|
|
28575
28586
|
});
|
|
28576
28587
|
res.end(html);
|
|
28577
28588
|
} catch (error) {
|