Skip to content

feat(debug-proxy-errors-plugin): diagnostic message for POST + bodyParser + ECONNRESET error - #1273

Merged
chimurai merged 1 commit into
masterfrom
debug-message-bodyparser-econnreset
Jun 25, 2026
Merged

chimurai merged 1 commit into
masterfrom
debug-message-bodyparser-econnreset

Conversation

@chimurai

@chimurai chimurai commented Jun 25, 2026 •

Copy link
Copy Markdown
Owner

resolves: #40

Add debug message to help developer fix ECONNRESET error when POST requests with a bodyParser middleware are used.

image

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved proxy error handling when the request body was already parsed and the upstream connection resets.
    • Enhanced console error output for the specific POST + ECONNRESET case.
  • Tests

    • Added end-to-end coverage to verify the proxy returns 504 and emits a single console error containing the [ERR_HPM.GH40] identifier.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9dc117c4-d955-4afc-ae3c-e826969bda14

📥 Commits

Reviewing files that changed from the base of the PR and between bfa9fbd and aaaf09c.

📒 Files selected for processing (2)
  • src/plugins/default/debug-proxy-errors-plugin.ts
  • test/e2e/http-proxy-middleware.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/plugins/default/debug-proxy-errors-plugin.ts
  • test/e2e/http-proxy-middleware.spec.ts

📝 Walkthrough

Walkthrough

Adds a styled debug log for ECONNRESET errors when a POST request already has a parsed body, and adds an end-to-end test covering the reset case and expected 504 response.

Changes

Body-parser proxy reset logging

Layer / File(s) Summary
Error logging check
src/plugins/default/debug-proxy-errors-plugin.ts
Imports styleText, adds a body-parser guidance message, and logs it on ECONNRESET for POST requests with an existing req.body.
E2E reset test
test/e2e/http-proxy-middleware.spec.ts
Sets up bodyParser.json(), simulates an upstream reset on POST /api, checks for 504, and verifies one [ERR_HPM.GH40] console error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I twitched my nose at proxy rain,
and found a reset in the chain.
A crimson note now helps me see,
why POST got lost by ECONNRESET sea.
Hop-hop—504 is finally tame!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the new diagnostic message for POST requests affected by bodyParser and ECONNRESET.
Linked Issues check ✅ Passed The change addresses issue #40 by detecting parsed POST bodies on ECONNRESET and emitting actionable guidance.
Out of Scope Changes check ✅ Passed The patch stays focused on the proxy error diagnostic and its matching E2E coverage, with no unrelated changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch debug-message-bodyparser-econnreset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/http-proxy-middleware@1273

commit: aaaf09c

@coveralls

coveralls commented Jun 25, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 95.227% (+0.04%) from 95.183% — debug-message-bodyparser-econnreset into master

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/plugins/default/debug-proxy-errors-plugin.ts`:
- Around line 33-36: The GH40 body-parser check in debug-proxy-errors-plugin is
too loose because it only tests for the presence of req.body, so unrelated
ECONNRESET errors can still trigger the guidance. Tighten the predicate in the
request/error handling block around BODY_PARSER_ERROR_MESSAGE to require an
actually populated parsed body (for example, a non-empty object/array or other
real content) before logging, while keeping the existing req.method === 'POST'
and ECONNRESET conditions in place.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84a23401-86b2-40f4-b5d0-df49a0ef5666

📥 Commits

Reviewing files that changed from the base of the PR and between 006f1a4 and 384cdb4.

📒 Files selected for processing (2)
  • src/plugins/default/debug-proxy-errors-plugin.ts
  • test/e2e/http-proxy-middleware.spec.ts

Comment thread src/plugins/default/debug-proxy-errors-plugin.ts Outdated
@chimurai
chimurai force-pushed the debug-message-bodyparser-econnreset branch from 384cdb4 to bfa9fbd Compare June 25, 2026 17:17
@chimurai chimurai changed the title feat(debug-proxy-errors-plugin): debug message for POST + bodyParser + ECONNRESET error feat(debug-proxy-errors-plugin): diagnostic message for POST + bodyParser + ECONNRESET error Jun 25, 2026
@chimurai
chimurai force-pushed the debug-message-bodyparser-econnreset branch from bfa9fbd to aaaf09c Compare June 25, 2026 18:44
@chimurai
chimurai merged commit 7ba87a9 into master Jun 25, 2026
26 checks passed
@chimurai
chimurai deleted the debug-message-bodyparser-econnreset branch June 25, 2026 19:02
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.

POST request body is not proxied to the servers

2 participants