-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Handle "ReplyError: ERR Unknown worker" from faktory server #117
base: main
Are you sure you want to change the base?
Handle "ReplyError: ERR Unknown worker" from faktory server #117
Conversation
src/client.ts
Outdated
@@ -236,11 +236,15 @@ export class Client { | |||
*/ | |||
async beat(): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This this method is a bit low-level, I would prefer for it to reject the promise when it fails sending the beat to the server. Callers of Client#beat
could then catch that error where necessary. As it's written, a caller of Client#beat
would have no way of knowing whether it succeeded or not, because it returns a truthy value either way.
Since beat
is already wrapped in a try/catch in Worker#work
as of 4.1.0, do you think it will be okay if we don't try/catch here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your inputs, I will upgrade the package and test this try/catch in Worker#work
and provide an update
And I think stopping the worker during this error seems to be the best thing to do @jbielick
I can update the PR later today!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Josh, @jbielick
4.1.4
seems to handle the error signal in the catch block!
What do you think about shutting the worker down when the heartbeat to the server fails unexpectedly? That could be done in the faktory_worker_node/src/worker.ts Lines 209 to 214 in 297a82f
If the server responded with a healthy response to the beat, no error would be thrown and things would work normally. The code should only ever enter the |
Issue:
Faktory returning
ReplyError: ERR Unknown worker
is not handled inclient.ts
resulting in the below exception,Cause:
Currently, the issue is raised in this line, Client.ts #L239
Cause of the issue:
The unhandled error has been explained in detail in this open Issue #116
Error from faktory-server originates in Faktory commands.go#L223
The error was replicated and the fix was tested in a separate project with the following env:
node.js version: v12.16.2
npm/yarn version: 6.14.11
faktory-server version: 1.4.2
faktory-worker package version: 4.0.1
Added a test for this case in
src/__tests__/client.test.ts
@jbielickLet me know if this is valid!
Otherwise, we can send a
terminate
signal back to the worker too if that's the proper fix, please advise!References: