Handle "ReplyError: ERR Unknown worker" from faktory server#117
Handle "ReplyError: ERR Unknown worker" from faktory server#117Laksh47 wants to merge 3 commits intojbielick:mainfrom
Conversation
| @@ -236,11 +236,15 @@ export class Client { | |||
| */ | |||
| async beat(): Promise<string> { | |||
There was a problem hiding this comment.
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.
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.
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 workeris not handled inclient.tsresulting 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
terminatesignal back to the worker too if that's the proper fix, please advise!References: