@lark-apaas/devtool-kits 1.0.5-alpha.1 → 1.0.5-alpha.2
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 +4 -14
- package/dist/index.cjs +11 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +11 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28534,7 +28534,7 @@ function injectErrorData(template, errorLogs) {
|
|
|
28534
28534
|
}
|
|
28535
28535
|
__name(injectErrorData, "injectErrorData");
|
|
28536
28536
|
function handleDevProxyError(err, req, res, options) {
|
|
28537
|
-
const { logDir = path2.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "server.log", retryTimeout = 5e3, retryInterval = 500, target
|
|
28537
|
+
const { logDir = path2.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "server.log", retryTimeout = 5e3, retryInterval = 500, target } = options || {};
|
|
28538
28538
|
console.error("[Proxy Error]:", err.message);
|
|
28539
28539
|
if (res.headersSent) {
|
|
28540
28540
|
console.error("[Proxy Error]: Headers already sent, cannot send error page");
|
|
@@ -28558,14 +28558,13 @@ function handleDevProxyError(err, req, res, options) {
|
|
|
28558
28558
|
console.log(`[Proxy Error]: Waiting for service recovery at ${host}:${port} (timeout: ${retryTimeout}ms)...`);
|
|
28559
28559
|
const recovered = await waitForServiceRecovery(host, port, retryTimeout, retryInterval);
|
|
28560
28560
|
if (recovered) {
|
|
28561
|
-
console.log("[Proxy Error]: Service recovered, sending
|
|
28562
|
-
|
|
28563
|
-
|
|
28561
|
+
console.log("[Proxy Error]: Service recovered, sending redirect");
|
|
28562
|
+
sendSimpleRedirect(req, res);
|
|
28563
|
+
return;
|
|
28564
28564
|
}
|
|
28565
|
+
console.log("[Proxy Error]: Service did not recover within timeout, showing error page");
|
|
28565
28566
|
}
|
|
28566
|
-
|
|
28567
|
-
if (redirected) return;
|
|
28568
|
-
console.log("[Proxy Error]: Falling back to scenario 2 (detailed error page)");
|
|
28567
|
+
console.log("[Proxy Error]: Falling back to scenario 2 (detailed error page with probe)");
|
|
28569
28568
|
}
|
|
28570
28569
|
console.log("[Proxy Error]: Compile error or non-connection error, showing error page");
|
|
28571
28570
|
const template = getErrorHtmlTemplate();
|
|
@@ -28587,45 +28586,17 @@ function handleDevProxyError(err, req, res, options) {
|
|
|
28587
28586
|
})();
|
|
28588
28587
|
}
|
|
28589
28588
|
__name(handleDevProxyError, "handleDevProxyError");
|
|
28590
|
-
function
|
|
28591
|
-
|
|
28592
|
-
const urlObj = new URL(url, "http://localhost");
|
|
28593
|
-
const retryCount = urlObj.searchParams.get("_retry_count");
|
|
28594
|
-
return retryCount ? parseInt(retryCount, 10) : 0;
|
|
28595
|
-
} catch {
|
|
28596
|
-
return 0;
|
|
28597
|
-
}
|
|
28598
|
-
}
|
|
28599
|
-
__name(getRedirectCount, "getRedirectCount");
|
|
28600
|
-
function addRedirectCount(url, count) {
|
|
28601
|
-
try {
|
|
28602
|
-
const urlObj = new URL(url, "http://localhost");
|
|
28603
|
-
urlObj.searchParams.set("_retry_count", String(count));
|
|
28604
|
-
return urlObj.pathname + urlObj.search;
|
|
28605
|
-
} catch {
|
|
28606
|
-
return url;
|
|
28607
|
-
}
|
|
28608
|
-
}
|
|
28609
|
-
__name(addRedirectCount, "addRedirectCount");
|
|
28610
|
-
function sendSimpleRetryResponse(req, res, maxRedirects) {
|
|
28611
|
-
if (res.headersSent) return true;
|
|
28589
|
+
function sendSimpleRedirect(req, res) {
|
|
28590
|
+
if (res.headersSent) return;
|
|
28612
28591
|
const originalUrl = req.url || "/";
|
|
28613
|
-
|
|
28614
|
-
if (currentCount >= maxRedirects) {
|
|
28615
|
-
console.log(`[Proxy Error]: Max redirects (${maxRedirects}) reached, will show detailed error page`);
|
|
28616
|
-
return false;
|
|
28617
|
-
}
|
|
28618
|
-
const nextCount = currentCount + 1;
|
|
28619
|
-
const redirectUrl = addRedirectCount(originalUrl, nextCount);
|
|
28620
|
-
console.log(`[Proxy Error]: Redirecting (attempt ${nextCount}/${maxRedirects}) to ${redirectUrl}`);
|
|
28592
|
+
console.log("[Proxy Error]: Sending 302 redirect to", originalUrl);
|
|
28621
28593
|
res.writeHead(302, {
|
|
28622
|
-
"Location":
|
|
28594
|
+
"Location": originalUrl,
|
|
28623
28595
|
"Cache-Control": "no-cache, no-store, must-revalidate"
|
|
28624
28596
|
});
|
|
28625
28597
|
res.end();
|
|
28626
|
-
return true;
|
|
28627
28598
|
}
|
|
28628
|
-
__name(
|
|
28599
|
+
__name(sendSimpleRedirect, "sendSimpleRedirect");
|
|
28629
28600
|
|
|
28630
28601
|
// src/middlewares/index.ts
|
|
28631
28602
|
import path5 from "path";
|