Skip to content

Commit

Permalink
refactor(dev): attach worker reload error as cause (#2651)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pooya@pi0.io>
  • Loading branch information
tobiasdiez and pi0 committed Sep 20, 2024
1 parent 12c39e4 commit 1fa2b5e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/dev-server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ function initWorker(filename: string): Promise<NitroWorker> | undefined {
)
);
});
worker.once("error", (err) => {
const newErr = new Error("[worker init] " + err.message);
newErr.stack = err.stack;
reject(newErr);
worker.once("error", (error) => {
const newError = new Error(`[worker init] ${filename} failed`, {
cause: error,
});
if (Error.captureStackTrace) {
Error.captureStackTrace(newError, initWorker);
}
reject(newError);
});
const addressListener = (event: any) => {
if (!event || !event?.address) {
Expand Down

0 comments on commit 1fa2b5e

Please sign in to comment.