Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proxy POST #168

Merged
merged 5 commits into from
May 24, 2024
Merged

Fix proxy POST #168

merged 5 commits into from
May 24, 2024

Conversation

steve9164
Copy link
Member

@steve9164 steve9164 commented May 13, 2024

  • Fix upstream proxied POST request being aborted early on Node 16+
  • Include node 16 in tests
  • Fix warning

Node 16 changed when the "close" event of IncomingMessage req is fired. This used to be fired when the socket was closed before the request finished. Now, to better match the ReadableStream interface, it is fired when the stream representing the downstream request (from TerriaMap) closes - i.e. when the entire request has been parsed by node.js - so this event is now fired for every request and in most cases before the proxied request has finished. Since our proxy controller aborts the upstream request on this event, that means that our proxy controller is now trying to abort every upstream request. This seems to only affect POST requests, but it's possible it could affect GET requests in certain cases.

The fix included here is to rather use the "close" event of the ServerResonse res. This stream will be closed after a successfully finished response, or if the socket is closed.

Due to change in meaning of 'close' event, which was changed to match the Stream interface instead of events of the socket
@@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 21.x]
node-version: [16.x, 18.x, 20.x, 22.x]
Copy link
Contributor

Choose a reason for hiding this comment

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

Node 16 had its security support end 8 months ago, how long do you plan to support it?

@steve9164 steve9164 merged commit b02b16c into master May 24, 2024
8 checks passed
@steve9164 steve9164 deleted the fix-proxy-post branch May 24, 2024 01:50
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.

None yet

3 participants