-
Notifications
You must be signed in to change notification settings - Fork 2
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
DTP-711: Handle SequenceId edge cases #163
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
We should catch any error thrown by the We should add a comment to clarify that the inner retry will stop due to the errored state being set on the model. It would be good to add a unit test for this behaviour to assert that we do not get into a retry loop when there is a stream discontinuity and the resync throws. We should also update docs to state when the sync or subscribe promise rejects. You can then run |
9ea4c38
to
f976bb1
Compare
f976bb1
to
36ba0a6
Compare
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.
Looks good, minor comments then happy to merge :)
src/Model.ts
Outdated
try { | ||
await this.retryable(fixedRetryStrategy(delay), fn); | ||
} catch (err) { | ||
this.logger.warn('failed to resume after error', { ...this.baseLogContext, action: 'handleErrorResume', err }); |
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.
I think this should be error level
8bf2f3c
to
a53c505
Compare
6ff2d22
to
25ec24a
Compare
Let's merge #164 into this and then happy to approve :) |
This PR adds tests and validation handling for the sequenceId return from the configured sync function.
Conditions:
undefined
'0'
and there is history in the channel. In which case history should be applied.Previous PR: #162, I had to change the branch name because I used the wrong jira reference. Old comments are here are on the original PR
Comments
In condition 1 where the sequenceId is
undefined
, the solution in this PR is throw an error and set the model state toerrored
. Additionally theretryable()
logic has been updated to not run the callback function if the model is in theerrored
state. Additionally if we catch an error while in the errored state then we re throw it, propagating it up the call stack. This is how the newsequenceId is undefined error
will be surfaced to the user.Other changes
Error handling has been improved so that all errors produced by the SDK during event handling function or in places where a user would not be able to catch them have been silenced and are exposed through the 'errored' event.
The docs around the Models's sync and subscribe methods have been updated so that the user knows to catch any errors thrown by these functions.
An integration test has been added that covers all message history being applied to model with sequenceId 0 and, seek and applying history with a sequenceId of 1 or more.
The
uuid
package has been added as a dev dependancy.The current integration test located in
./src/Model.integration.test.ts
has been wrapped in its own describe as the test set up new test is different. This test are now isolated. I have also added uuids to the channel name so that each test run uses a different channel.