Skip to content

Treat ABORTED writes as retryable #1456

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

Merged
merged 3 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/firestore/src/remote/remote_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,9 @@ export class RemoteStore implements TargetMetadataProvider {
}

private async handleHandshakeError(error: FirestoreError): Promise<void> {
// Reset the token if it's a permanent error or the error code is
// ABORTED, signaling the write stream is no longer valid.
if (isPermanentError(error.code) || error.code === Code.ABORTED) {
// Reset the token if it's a permanent error, signaling the write stream is
// no longer valid.
if (isPermanentError(error.code)) {
log.debug(
LOG_TAG,
'RemoteStore error before completed handshake; resetting stream token: ',
Expand All @@ -664,7 +664,10 @@ export class RemoteStore implements TargetMetadataProvider {
}

private async handleWriteError(error: FirestoreError): Promise<void> {
if (isPermanentError(error.code)) {
// Only handle permanent errors here. If it's transient, just let the retry
// logic kick in. As of b/119437764, ABORTED errors on the write stream
// should be retried too.
if (isPermanentError(error.code) && error.code !== Code.ABORTED) {
// This was a permanent error, the request itself was the problem
// so it's not going to succeed if we resend it.
const batch = this.writePipeline.shift()!;
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/test/unit/specs/write_spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ describeSpec('Writes:', [], () => {
Code.ALREADY_EXISTS,
Code.PERMISSION_DENIED,
Code.FAILED_PRECONDITION,
Code.ABORTED,
Code.OUT_OF_RANGE,
Code.UNIMPLEMENTED,
Code.DATA_LOSS
Expand Down Expand Up @@ -697,6 +696,7 @@ describeSpec('Writes:', [], () => {
);

for (const code of [
Code.ABORTED,
Code.CANCELLED,
Code.UNKNOWN,
Code.DEADLINE_EXCEEDED,
Expand Down