Skip to content

Commit 615f831

Browse files
committed
Merge branch 'bugfix/CLDSRV-716-fix-default-timeout' into tmp/octopus/w/9.1/bugfix/CLDSRV-716-fix-default-timeout
2 parents a829f76 + d937714 commit 615f831

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

lib/server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ class S3Server {
248248
});
249249
}
250250

251+
// Starting NodeJS v18, the default timeout, when `undefined`, is
252+
// 5 minutes. We must set the value to zero to allow for long
253+
// upload durations.
254+
server.requestTimeout = 0; // disabling request timeout
255+
251256
server.on('connection', socket => {
252257
socket.on('error', err => logger.info('request rejected',
253258
{ error: err }));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenko/cloudserver",
3-
"version": "9.0.19",
3+
"version": "9.0.20",
44
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
55
"main": "index.js",
66
"engines": {

tests/unit/server.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const assert = require('assert');
44
const sinon = require('sinon');
5+
const http = require('http');
6+
const https = require('https');
57
const arsenal = require('arsenal');
68
const uuid = require('uuid');
79
const logger = require('../../lib/utilities/logger');
@@ -210,3 +212,41 @@ describe('S3Server', () => {
210212
});
211213
});
212214
});
215+
216+
describe('S3Server request timeout', () => {
217+
let sandbox;
218+
let mockServer;
219+
220+
beforeEach(() => {
221+
sandbox = sinon.createSandbox();
222+
223+
// Create a mock server to capture the requestTimeout setting
224+
mockServer = {
225+
requestTimeout: null,
226+
on: sandbox.stub(),
227+
listen: sandbox.stub(),
228+
address: sandbox.stub().returns({ address: '127.0.0.1', port: 8000 }),
229+
};
230+
231+
// Mock server creation to return our mock
232+
sandbox.stub(http, 'createServer').returns(mockServer);
233+
sandbox.stub(https, 'createServer').returns(mockServer);
234+
});
235+
236+
afterEach(() => {
237+
sandbox.restore();
238+
});
239+
240+
it('should set server.requestTimeout to 0 when starting server', () => {
241+
const server = new S3Server({
242+
...defaultConfig,
243+
https: false
244+
});
245+
246+
// Call _startServer which should set requestTimeout = 0
247+
server._startServer(() => {}, 8000, '127.0.0.1');
248+
249+
// Verify that requestTimeout was set to 0
250+
assert.strictEqual(mockServer.requestTimeout, 0);
251+
});
252+
});

0 commit comments

Comments
 (0)