@lasso-ai/cli 1.0.10 → 1.0.11
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/host/daemon.js
CHANGED
|
@@ -128,6 +128,7 @@ class LassoHost {
|
|
|
128
128
|
throw new Error(result.error || `Could not start ${domain}.`);
|
|
129
129
|
}
|
|
130
130
|
const runtime = result.runtime;
|
|
131
|
+
this.crashLog.delete(domain);
|
|
131
132
|
this.running.set(domain, runtime);
|
|
132
133
|
runtime.child.on("exit", (code, signal) => {
|
|
133
134
|
if (this.running.get(domain) === runtime) {
|
|
@@ -210,10 +211,12 @@ class LassoHost {
|
|
|
210
211
|
route: "POST /_host/restart",
|
|
211
212
|
handler: async (_req, res) => {
|
|
212
213
|
const stopped = [];
|
|
214
|
+
this.crashLog.clear();
|
|
213
215
|
for (const [domain, runtime] of this.running) {
|
|
214
216
|
runtime.child.kill("SIGTERM");
|
|
215
217
|
this.running.delete(domain);
|
|
216
218
|
this.cleanupOnStart.add(domain);
|
|
219
|
+
this.crashLog.delete(domain);
|
|
217
220
|
stopped.push(domain);
|
|
218
221
|
this.log(`stopped ${domain} for restart`);
|
|
219
222
|
}
|
|
@@ -229,6 +232,7 @@ class LassoHost {
|
|
|
229
232
|
return writeJson(res, 400, { ok: false, error: "A project domain is required." });
|
|
230
233
|
const runtime = this.running.get(domain);
|
|
231
234
|
this.cleanupOnStart.add(domain);
|
|
235
|
+
this.crashLog.delete(domain);
|
|
232
236
|
if (runtime) {
|
|
233
237
|
runtime.child.kill("SIGTERM");
|
|
234
238
|
this.running.delete(domain);
|
|
@@ -87,15 +87,18 @@ void (async () => {
|
|
|
87
87
|
const chunks = [];
|
|
88
88
|
proxyRes.on("data", (chunk) => chunks.push(chunk));
|
|
89
89
|
proxyRes.on("end", () => {
|
|
90
|
-
const body = Buffer.concat(chunks)
|
|
90
|
+
const body = Buffer.concat(chunks);
|
|
91
91
|
const contentType = String(proxyRes.headers["content-type"] || "");
|
|
92
92
|
const headers = { ...proxyRes.headers };
|
|
93
93
|
delete headers["content-length"];
|
|
94
94
|
delete headers["content-encoding"];
|
|
95
95
|
res.writeHead(proxyRes.statusCode || 200, headers);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (contentType.includes("text/html")) {
|
|
97
|
+
res.end(body.toString("utf8").replace("</head>", `<script src="/__lasso/overlay.js?bridgePort=${bridgePort}"></script></head>`));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
res.end(body);
|
|
101
|
+
}
|
|
99
102
|
});
|
|
100
103
|
});
|
|
101
104
|
const server = node_http_1.default.createServer((req, res) => {
|
|
@@ -104,12 +107,23 @@ void (async () => {
|
|
|
104
107
|
res.end(node_fs_1.default.readFileSync(bundlePath, "utf8"));
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const forward = (attempt = 0) => {
|
|
111
|
+
proxy.web(req, res, { headers: { "accept-encoding": "identity" } }, (error) => {
|
|
112
|
+
const retryable = error.code === "ECONNREFUSED" ||
|
|
113
|
+
error.code === "ECONNRESET" ||
|
|
114
|
+
error.code === "EPIPE";
|
|
115
|
+
if (!res.headersSent && req.method !== "POST" && retryable && attempt < 12) {
|
|
116
|
+
setTimeout(() => forward(attempt + 1), 250);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
console.error(`[lasso] Next proxy error for ${req.url}: ${error.message}`);
|
|
120
|
+
if (!res.headersSent) {
|
|
121
|
+
res.writeHead(502, { "content-type": "text/plain" });
|
|
122
|
+
res.end(`Next.js is still starting: ${error.message}`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
forward();
|
|
113
127
|
});
|
|
114
128
|
server.on("upgrade", (req, socket, head) => proxy.ws(req, socket, head));
|
|
115
129
|
try {
|
package/dist/cli/server/next.js
CHANGED
|
@@ -37,14 +37,14 @@ async function startNextServer(cwd) {
|
|
|
37
37
|
const chunks = [];
|
|
38
38
|
proxyRes.on("data", (chunk) => chunks.push(chunk));
|
|
39
39
|
proxyRes.on("end", () => {
|
|
40
|
-
const body = Buffer.concat(chunks)
|
|
40
|
+
const body = Buffer.concat(chunks);
|
|
41
41
|
const contentType = proxyRes.headers["content-type"] || "";
|
|
42
42
|
const headers = { ...proxyRes.headers };
|
|
43
43
|
delete headers["content-length"];
|
|
44
44
|
delete headers["content-encoding"];
|
|
45
45
|
res.writeHead(proxyRes.statusCode || 200, headers);
|
|
46
46
|
if (contentType.includes("text/html")) {
|
|
47
|
-
res.end(body.replace("</head>", `<script src="/__lasso/overlay.js?bridgePort=3056"></script></head>`));
|
|
47
|
+
res.end(body.toString("utf-8").replace("</head>", `<script src="/__lasso/overlay.js?bridgePort=3056"></script></head>`));
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
res.end(body);
|
package/package.json
CHANGED