Skip to content

Comments

fix: read HTTP response body before context cancellation#3146

Open
clarabennettdev wants to merge 1 commit intosuperplanehq:mainfrom
clarabennettdev:fix-http-context-canceled
Open

fix: read HTTP response body before context cancellation#3146
clarabennettdev wants to merge 1 commit intosuperplanehq:mainfrom
clarabennettdev:fix-http-context-canceled

Conversation

@clarabennettdev
Copy link

Fixes #3141

Problem

The HTTP component fails with failed to read response body: context canceled even when the server returns status 200. This happens because executeRequest creates a context with defer cancel(), which cancels the context when the function returns — before processResponse can read the response body.

Fix

Read the entire response body within executeRequest (while the context is still active) and replace resp.Body with a buffered io.NopCloser(bytes.NewReader(...)). This way processResponse can consume the body normally without context cancellation issues.

Minimal, targeted fix — no signature or control flow changes.

Fixes superplanehq#3141

In executeRequest, the request context is canceled via defer cancel()
when the function returns. However, the response body is read later in
processResponse, which causes 'context canceled' errors for large or
slow responses.

The fix reads the entire response body before executeRequest returns
(while the context is still active) and replaces resp.Body with a
buffered reader so processResponse can consume it normally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP component: context canceled when reading response body

1 participant