-
Notifications
You must be signed in to change notification settings - Fork 20
Implement Request Timeouts #172
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
base: main
Are you sure you want to change the base?
Conversation
This change implements request timeouts for any request sent to the Kafka cluster. The timeout's duration can be configured via option `requestTimeout` in every client type. Additionally, the retrying logic in the base class is changed so that it retries only if every error in the current error chain is marked as retriable. Otherwise, timeout errors, which should be handled as non-retriable errors, would potentially lead to much longer timeouts due to multiple attempts being made. (But also in general, I would assume that every non-retriable error encountered should block any additional attempt) on-behalf-of: @SAP ospo@sap.com
10601a1 to
305df00
Compare
ShogunPanda
left a comment
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 this, I love the idea.
Few modifications but nothing big.
| } | ||
|
|
||
| get status (): ConnectionStatusValue { | ||
| get status (): ConnectionStatus { |
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.
Why this change (and the types change above)?
| timedOut: false | ||
| } | ||
|
|
||
| this.#requestsQueue.push(fastQueueCallback => { |
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.
Rather than creating two functions here, I would use .bind.
this.#requestsQueue.push(fastQueueCallback => {
request.callback = fastQueueCallback
if (this.#socketMustBeDrained) {
this.#afterDrainRequests.push(request)
return false
}
return this.#sendRequest(request)
}, this.#onResponse.bind(this, request, callback))
And #onResponse (or similar) you clear the timeout and then invoke callback.
Similarly for the setTimeout below:
if (!request.noResponse) {
request.timeoutHandle = setTimeout(this.#onRequestTimeout.bind(this, request), this.#options.requestTimeout)
}
| this.#socket.removeListener('error', connectingSocketErrorHandler) | ||
|
|
||
| this.#socket.on('error', this.#onError.bind(this)) | ||
| this.#socket.on('error', this.#connectedSocketErrorHandler.bind(this)) |
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.
Please revert this.
| let mockCount = 1 | ||
| mockAPI(consumer[kConnections], consumerGroupHeartbeatV0.api.key, null, null, () => mockCount-- > 0) | ||
| mockAPI(consumer[kConnections], consumerGroupHeartbeatV0.api.key, null, null, ( | ||
| __originalSend, |
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.
Please only use a single _ in this call.
This change implements request timeouts for any request sent to the Kafka cluster. The timeout's duration can be configured via option
requestTimeoutin every client type.Additionally, the retrying logic in the base class is changed so that it retries only if every error in the current error chain is marked as retriable. Otherwise, timeout errors, which should be handled as non-retriable errors, would potentially lead to much longer timeouts due to multiple attempts being made.
(But also in general, I would assume that every non-retriable error encountered should block any additional attempt)
on-behalf-of: @SAP ospo@sap.com