Skip to content

fix(providers): cancel responses rejected by Content-Length - #43

Merged
haseebahmed248 merged 2 commits into
haseebahmed248:mainfrom
kudala-bharani:fix/cancel-oversized-provider-response
Sep 7, 2026
Merged

haseebahmed248 merged 2 commits into
haseebahmed248:mainfrom
kudala-bharani:fix/cancel-oversized-provider-response

Conversation

@kudala-bharani

@kudala-bharani kudala-bharani commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Responses rejected by their Content-Length left the unread body open. Start cancelling that body and return PROVIDER_RESPONSE_TOO_LARGE without waiting for cleanup to settle. Cleanup rejection is handled without replacing the known size failure.

Related issue

Closes #39

Changes

  • Start cancellation on the early size rejection; tolerate absent bodies, pending cleanup, and cleanup errors.
  • Add regression coverage for successful, rejected, and pending cancellation, plus a response without a body. Document the cleanup behavior.

Validation

  • npm run check
  • npm run check:generated
  • npm test — 60 passed
  • Additional validation is described below, or was not needed.

Additional validation: The cancellation tests failed before the fix because the callback was never called. The pending-cancellation test also fails if cleanup is awaited: it verifies that generation completes while cancellation remains pending, without a wall-clock timeout. npm run test:release passed all 4 tests, and npm run test:package verified the installable package. Local validation used Node.js 25.9.0.

Risk and compatibility

  • Security or permission effects: Cleanup is attempted for rejected responses; provider contents and cleanup errors are not exposed in results.
  • Compatibility or breaking changes: None. Public failure codes, response-size limits, and timeout handling are unchanged.

Checklist

  • This change is focused on one issue.
  • Behavioral changes include tests.
  • User-facing behavior and unsupported constructs are documented.
  • Generated files are current.
  • No credentials, private data, or unredacted model output are included.
  • Commits include the required DCO Signed-off-by line.

Signed-off-by: kudala-bharani <bunnykudala@gmail.com>

@haseebahmed248 haseebahmed248 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and tests. The type checks, generated-contract check and all 59 tests pass, and CI is green. Catching the cleanup error is appropriate here because it must not replace the known size failure. There is one pending-cancellation case to address, noted inline.

Signed-off-by: kudala-bharani <bunnykudala@gmail.com>
@haseebahmed248
haseebahmed248 merged commit 798c360 into haseebahmed248:main Sep 7, 2026
6 checks passed
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.

Cancel oversized provider response bodies rejected by Content-Length

2 participants