Skip to content

fix: keep HandleContext alive when a ForwardingResolver throws - #56

Merged
CypherPotato merged 1 commit into
mainfrom
fix/forwarding-resolver-log-crash
Oct 17, 2026
Merged

CypherPotato merged 1 commit into
mainfrom
fix/forwarding-resolver-log-crash

Conversation

@CypherPotato

Copy link
Copy Markdown
Member

Cause

When ForwardingResolver.OnResolveClientAddress throws, HandleContext correctly answers 500, but request.remoteAddr stays null. In the finally block, the default access log format (%ri) reads HttpRequest.RemoteAddress, which calls the resolver again and throws a second time. That exception escapes HandleContext:

  • default engine: it runs on a thread-pool work item, so the process terminates;
  • Cadente: the connection is closed without a response, and with AsyncRequestProcessing = false the Monitor.Exit is skipped and the server stays locked.

Fix

  • %ri uses the already resolved remoteAddr and no longer calls the resolver again.
  • Handlers and logging in the finally block are wrapped in try/catch, and the sync completion, Monitor.Exit and request disposal always run.

Test

ThrowingForwardingResolverReturns500AndKeepsServing covers the default and Cadente engines with AsyncRequestProcessing true and false: the resolver throws, the response is 500 and the next request is 200. Without the fix the test host crashes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T18:06:13.256109Z 828b101 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@CypherPotato
CypherPotato merged commit 9cc316b into main Oct 17, 2026
5 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.

1 participant