Skip to content

Conversation

@Corvince
Copy link

@Corvince Corvince commented Nov 22, 2025

Some small improvements and additions to the fetch path. Now additionally runs and passes all tests with the fetch path

@Corvince
Copy link
Author

finally resolved the websocket (not just test) errors. Just a few more tests error before fetch path passes all tests (except where not applicable)

primarily look for x-forwarded-host instead of host header
@Corvince
Copy link
Author

All tests passing :)

There were some remaining tests failing, which was due to the test expecting the "host" header to contain the port number of the proxy - something fetch doesnt allow you to do (the host header is forbidden do set manually and must always represent the actual host the request is made to. Additionally for h2, the host header doesn't even exist. The way I solved it was to add xfwd option and test again the x-forwarded-host header.

Now the only tests that are being skipped relate to the not supported proxyReq and proxyRes events, the preserveHeaderKeyCase (also not supported) and the body-decoder-middleware. Frankly I don't know that this test is about and why it fails, but this is a wont-fix for me.

@Corvince Corvince marked this pull request as ready for review November 25, 2025 20:51
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 241 to 245
if (options.proxyTimeout) {
setTimeout(() => {
controller.abort();
}, options.proxyTimeout);
}

Choose a reason for hiding this comment

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

P1 Badge Avoid aborting active fetches after proxyTimeout

In the fetch code path a setTimeout now calls controller.abort() after options.proxyTimeout elapses, but the timer is never cleared or coupled to socket inactivity. As a result any fetch request that legitimately streams longer than the configured timeout (e.g., large downloads) will always be aborted and reported as ECONNRESET, whereas the native path uses proxyReq.setTimeout which only fires when the socket is idle. This regresses long-running fetch-based proxies whenever proxyTimeout is set.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

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

That does seem like a good point. Uncancelled setTimeout's are a red flag.

Copy link
Author

Choose a reason for hiding this comment

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

I agree. Honestly the timeout handling is what copilot came up with after I asked it to improve error handling - not sure why it was added, but looked good enough (especially adding the AbortController seemed sensible). But yes, I will look into this

Copy link
Author

Choose a reason for hiding this comment

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

I removed the abortcontroller and just added a AbortSignal.timeout if proxyTimeout is set. This still cancels the request independent of it being still active, but actually chatgpt is wrong here and this is also what happens in the native path.

This also simplifies the code

@Corvince Corvince mentioned this pull request Nov 25, 2025
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.

2 participants