Skip to content

Commit

Permalink
Merge pull request #216 from bcgov/upload-test1
Browse files Browse the repository at this point in the history
Remove request timeouts for upload endpoints
  • Loading branch information
jatindersingh93 authored Oct 6, 2023
2 parents 64b9918 + 0822acc commit a584d21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These users will be the default owners for everything in the repo.
# Unless a later match takes precedence, the following users will be
# requested for review when someone opens a pull request.
* @jujaga @norrisng-bc @TimCsaky
* @jujaga @norrisng-bc @TimCsaky @jatindersingh93
8 changes: 8 additions & 0 deletions app/src/middleware/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ const currentUpload = (strict = false) => {
mimeType: mimeType
});

/**
* Removes the default 5 minute request timeout added in Node v18
* This change reverts the behavior to be similar to Node v16 and earlier
* This value should not be 0x7FFFFFFF as behavior becomes unpredictable
* @see {@link https://nodejs.org/en/blog/release/v18.0.0#http-timeouts}
*/
req.socket.server.requestTimeout = 0;

next();
};
};
Expand Down
10 changes: 8 additions & 2 deletions app/tests/unit/middleware/upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ describe('currentUpload', () => {
let req, res, next;

beforeEach(() => {
req = { get: jest.fn() };
req = {
get: jest.fn(),
socket: { server: {} }
};
res = {};
next = jest.fn();
});
Expand Down Expand Up @@ -52,7 +55,10 @@ describe('currentUpload', () => {

expect(req.currentUpload).toEqual(current);
expect(next).toHaveBeenCalledTimes(nextCount);
if (nextCount) expect(next).toHaveBeenCalledWith();
if (nextCount) {
expect(req.socket.server.requestTimeout).toEqual(0);
expect(next).toHaveBeenCalledWith();
}
});
});

0 comments on commit a584d21

Please sign in to comment.