Handle stale frontend assets and harden worker startup
这个提交包含在:
@@ -13,9 +13,17 @@ export function serveStatic(app: Express) {
|
||||
);
|
||||
}
|
||||
|
||||
app.use(express.static(distPath));
|
||||
app.use(express.static(distPath, { index: false }));
|
||||
|
||||
app.use("*", (req, res) => {
|
||||
// Missing files under /assets or any path with an extension must return 404.
|
||||
// Falling back to index.html causes browsers to report MIME errors on stale chunks.
|
||||
const requestPath = req.originalUrl.split("?")[0];
|
||||
if (path.extname(requestPath)) {
|
||||
res.status(404).type("text/plain").send("Not found");
|
||||
return;
|
||||
}
|
||||
|
||||
app.use("*", (_req, res) => {
|
||||
res.sendFile(path.resolve(distPath, "index.html"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,9 +35,14 @@ async function workOnce() {
|
||||
async function main() {
|
||||
console.log(`[worker] ${workerId} started`);
|
||||
for (;;) {
|
||||
const hasWorked = await workOnce();
|
||||
if (!hasWorked) {
|
||||
await sleep(ENV.backgroundTaskPollMs);
|
||||
try {
|
||||
const hasWorked = await workOnce();
|
||||
if (!hasWorked) {
|
||||
await sleep(ENV.backgroundTaskPollMs);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[worker] loop error", error);
|
||||
await sleep(Math.max(ENV.backgroundTaskPollMs, 3_000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户