-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Log uncaught exceptions in worker thread handlers #1544
Conversation
thank you @aldenquimby ! regarding your first attempt, that might be a problem with logging and worker threads: nodejs/node#30491 I think it might be nice to see which handler (function key) actually caused the problem. I'll have a look at your first attempt and the log not showing up. |
@dnalborczyk ok great, thank you. Another possible solution if you want to ensure the function name shows: } catch (e) {
throw new RethrownError(`Uncaught error in '${this.#functionKey}' handler.`, e)
} And we'd need to create class RethrownError extends Error {
constructor(message, error) {
super(message)
this.name = this.constructor.name
this.stack = error.stack
}
} That seems cleaner to me because then there's just one place errors are logged (in HttpServer.js), vs having Thoughts on this approach? |
@aldenquimby I try to find some time over the weekend to have a closer look. I like your ideas, I just want to see what exactly is wrong. I don't know crazy much about worker threads and the usage in the plugin is pretty much my first and only attempt. just wanted to mention a couple things as food for thought: serverless-offline/src/lambda/handler-runner/in-process-runner/InProcessRunner.js Line 92 in 07cdd04
the second handler call serverless-offline/src/lambda/handler-runner/in-process-runner/InProcessRunner.js Line 109 in 07cdd04
|
@aldenquimby I pulled in your PR and added this: 06d348d . does this still cover your expectations? one of the problems was that the serverless/utils logger did not seem to work in a worker thread, but console.log did. (I didn't feel like digging into it). |
@dnalborczyk yes I just upgraded to v9.2.6 and error logs are working for me now, thank you! |
Motivation and Context
serverless-offline/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js
Lines 40 to 43 in 0f6c9f4
serverless-offline/src/events/http/HttpServer.js
Lines 615 to 619 in 0f6c9f4
How Has This Been Tested?
npm run lint
passes locallynpm run test:unit
- cannot get this to work locally.jest
dependency appears to be missing?