Skip to content

Commit

Permalink
Improve worker error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ServerlessLife committed Apr 8, 2024
1 parent 42484a2 commit 231744e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/nodeWorker.ts
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ export async function runInWorker(input: {
resolve(msg);
}
});
worker.on("error", (err) => {
console.log("Worker error", err);
reject(err);
});

worker.postMessage({
env: input.fuctionRequest.env,
@@ -74,10 +78,10 @@ function startWorker(input: {
);

worker.stdout.on("data", (data: Buffer) => {
console.log("stdout", data.toString());
console.log("WORKER: ", data.toString());
});
worker.stderr.on("data", (data: Buffer) => {
console.log("stderr", data.toString());
console.log("WORKER ERROR: ", data.toString());
});
worker.on("exit", () => {
console.log(`Worker ${input.workerID} exited`);

0 comments on commit 231744e

Please sign in to comment.