Fix: surface HTTP 413 and other 4xx errors via replication error event (issue #9165)#9236
Closed
TeapoyY wants to merge 1 commit intoapache:masterfrom
Closed
Fix: surface HTTP 413 and other 4xx errors via replication error event (issue #9165)#9236TeapoyY wants to merge 1 commit intoapache:masterfrom
TeapoyY wants to merge 1 commit intoapache:masterfrom
Conversation
Issue apache#9165: HTTP 413 during live replication is not surfaced via replication events. Root cause: In completeReplication(), only 'unauthorized' (401) and 'forbidden' (403) errors are emitted via the 'error' event. All other errors (including HTTP 413 Payload Too Large from _bulk_docs) fall through to the backoff/retry path. Fix: Treat 4xx client errors (except 401/403 already handled) the same as auth errors - emit them via the 'error' event and stop retrying. This is correct because 4xx errors indicate a problem with the request itself (e.g., content too large, bad request) that retrying cannot fix. The error is now properly surfaced to users via the 'error' event on the replication object.
Member
|
Thanks for the contribution. Can you please use our pull request template? |
Author
|
Closing - not a bounty issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #9165 — HTTP 413 during live replication is not surfaced via replication events.
Problem
When using PouchDB live replication with CouchDB, a \413 Content Too Large\ response from _bulk_docs\ is visible in DevTools but not exposed through any replication event. The \paused(err)\ event receives \err === undefined.
Root Cause
In \completeReplication(), only 'unauthorized'\ (401) and 'forbidden'\ (403) errors are emitted via the 'error'\ event. All other errors (including HTTP 413 Payload Too Large from _bulk_docs) fall through to the backoff/retry path, causing infinite retries without surfacing the error.
Fix
Treat 4xx client errors (except 401/403 already handled) the same as auth errors — emit them via the 'error'\ event and stop retrying. This is correct because 4xx errors indicate a problem with the request itself (e.g., content too large, bad request) that retrying cannot fix.
The fix is in \packages/node_modules/pouchdb-replication/src/replicate.js:
\\javascript
} else if (fatalError.status >= 400 && fatalError.status < 500) {
// Surface 4xx client errors (e.g. 413 Content Too Large from _bulk_docs)
// via the error event instead of retrying, since retrying won't fix them.
returnValue.emit('error', fatalError);
returnValue.removeAllListeners();
}
\\
Behavior Change
eplication.on('error', err => ...)\ receives the actual error with status/details