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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [push, pull_request]

# When a PR is updated, cancel the jobs from the previous version. Merges
# do not define head_ref, so use run_id to never cancel those jobs.
Expand All @@ -18,7 +14,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?


steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Next version

### 4.0.1

* Fixed proxied upstream POST request being aborted when the stream associated with the downstream request is closed on Node v16+. This will now again correctly be triggered only when the socket is closed early.

### 4.0.0

* Removed conversion service (no longer used in TerriaJS 8+).
Expand Down
4 changes: 2 additions & 2 deletions lib/controllers/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ module.exports = function(options) {
// encoding : null means "body" passed to the callback will be raw bytes

var proxiedRequest;
req.on('close', function() {
if (proxiedRequest) {
res.once('close', function() {
if (proxiedRequest && !res.writableEnded) {
proxiedRequest.abort();
}
});
Expand Down
2 changes: 1 addition & 1 deletion spec/proxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('proxy', function() {
request(buildApp(openProxyOptions))
[methodName]('/_2h/example.com')
.set('Cache-Control', 'no-cache')
.set('x-give-response-status', '500')
.set('x-give-response-status', 500)
.expect(500)
.expect('cache-control', 'no-cache')
.end(assert(done));
Expand Down