mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-18 05:02:15 +03:00
fix(cli): normalize instrumentation boot errors
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
@@ -34,9 +34,10 @@ export async function register(registerNodejsFn?: () => Promise<void>) {
|
||||
// up while every DB-touching route 500s forever with a permanently
|
||||
// empty app.log. This guarantees stdout/app.log is never silently
|
||||
// empty on a failed boot, regardless of platform or which step threw.
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const normalizedError = err instanceof Error ? err : new Error(String(err));
|
||||
const message = normalizedError.message;
|
||||
console.error("[STARTUP] Fatal: instrumentation hook failed during boot:", message);
|
||||
throw err;
|
||||
throw normalizedError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,15 @@ test("#10171: a non-Error throw during instrumentation-hook boot is still logged
|
||||
};
|
||||
|
||||
try {
|
||||
await assert.rejects(() => register(fakeRegisterNodejs));
|
||||
await assert.rejects(
|
||||
() => register(fakeRegisterNodejs),
|
||||
(err: unknown) => {
|
||||
assert.ok(err instanceof Error, "register() must rethrow a real Error instance");
|
||||
err.message += " (augmented by Next)";
|
||||
assert.equal(err.message, "raw string boot failure (augmented by Next)");
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
const fatalLine = captured.find(
|
||||
(line) => line.includes("[STARTUP] Fatal:") && line.includes("raw string boot failure")
|
||||
|
||||
Reference in New Issue
Block a user