mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: resolve 5 Sentry production errors (668 total events)
- Filter known client-error noise (rate limit, empty body, unsupported media type, content-length mismatch, premature close) from Sentry via beforeSend to stop 644 events of non-actionable noise - Sanitize x-output-filename header to prevent TypeError on non-ASCII filenames in optimize-for-web preview (23 events) - Handle EPIPE on Python dispatcher stdin write with graceful fallback to per-request spawning instead of crashing (NODE-W) - Map EACCES on storage directory/file write to proper 503 status instead of generic 500 (NODE-P, 3 events)
This commit is contained in:
@@ -153,6 +153,8 @@ function startDispatcher(): ChildProcess | null {
|
||||
env: buildMinimalEnv(),
|
||||
});
|
||||
|
||||
child.stdin?.on("error", () => {});
|
||||
|
||||
let stderrBuffer = "";
|
||||
|
||||
child.stderr?.on("data", (chunk: Buffer) => {
|
||||
@@ -328,7 +330,13 @@ function dispatcherRun(
|
||||
});
|
||||
|
||||
const request = JSON.stringify({ id, script: scriptName.replace(".py", ""), args });
|
||||
proc.stdin!.write(request + "\n");
|
||||
try {
|
||||
proc.stdin!.write(request + "\n");
|
||||
} catch {
|
||||
pendingRequests.delete(id);
|
||||
clearTimeout(timer);
|
||||
rejectPromise(new Error("Python dispatcher stdin closed unexpectedly"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -537,7 +545,10 @@ export function runPythonWithProgress(
|
||||
const dispatcherPromise = dispatcherRun(scriptName, args, options);
|
||||
if (dispatcherPromise) {
|
||||
return dispatcherPromise.catch((err: Error) => {
|
||||
if (err.message === "Python dispatcher exited unexpectedly") {
|
||||
if (
|
||||
err.message === "Python dispatcher exited unexpectedly" ||
|
||||
err.message === "Python dispatcher stdin closed unexpectedly"
|
||||
) {
|
||||
console.warn(
|
||||
`[bridge] Dispatcher crashed during ${scriptName}, retrying with per-request process`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user