js-sdk
js-sdk copied to clipboard
Check Retryable/Non-Retryable Error for Subscribed Events and Action Accordingly
Describe the proposal
When an app subscribes to messages/events, it needs to send back status as per https://docs.dapr.io/reference/api/pubsub_api/. Whether a message needs to be retried or dropped, should ideally depend on whether error encountered is retryable or not.
The callback function looks like this currently:
const cb = function (data: any) {
// process the message
// if error is thrown, message will be DROPPED
// else message will be ACKED
}
We need to change it to something similar to
const cb = function (data: any): PubSubCallbackResponse {
const result = processMessage();
if (isSuccess(result)) { return PubSubCallbackResponseMessage.Ack; }
else if (needsRetry(result)) { return PubSubCallbackResponseMessage.Retry; }
else { return PubSubCallbackResponseMessage.Drop; }
}
Note, this will be a breaking change in terms of the SDK contract, hence is being triaged to the next major release.