fix: eliminate Location double-wrap 500 on document PUT (v1.4.1) - #13
Merged
Conversation
Rewrite absolute same-origin Location headers only in toClientResponse/toClientResponseFromCouch. fetchFromCouch now returns the raw upstream Response so undici no longer intermittently throws "body disturbed or locked" on successful PUT/COPY (client 500). Co-authored-by: Peter Baker <PeterBaker0@users.noreply.github.com>
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
Intermittent client
500on successful document PUT/COPY when Couch returns an absoluteLocation(e.g.http://couchdb:5984/...). Root cause:fetchFromCouchwrapped the upstreamResponseto rewriteLocation, thentoClientResponsewrapped the same body again — undici occasionally throwsTypeError: Response body object should not be disturbed or locked, whichapp.onErrormaps to Couch-shapedinternal_server_error.Fixed
Changes
new Response(...)fromfetchFromCouch(returns raw upstream).toClientResponseFromCouchso every client-facing upstream body rewrite happens once, with Couch-originLocation→ path-only.actors.tscall sites to use the helper (includingdocDelete/docUpdate/ error short-circuits that previously omittedrewriteLocation).test/unit/forward-location.test.ts; integration PUT Location + 20-create stress loop intest/integration/acl.test.ts.Follow-up after merge
./scripts/release.sh 1.4.1(GHCR1.4.1+sha-<short>).imageTag1.4.0→1.4.1and dropputWithRetryif desired.Test plan
pnpm fmt:check && pnpm lint && pnpm typecheck && pnpm testdocker compose up -d --build && pnpm test:integration(151 passed)201withLocation: /acldemo/doc-location-probe(no Couch origin)