Skip to content

Commit 390fd97

Browse files
committed
Merge branch 'bugfix/ARSN-263/cb' into q/8.1
2 parents a4f163f + 1c9e4eb commit 390fd97

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/s3routes/routesUtils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DataWrapper from '../storage/data/DataWrapper';
77
import * as http from 'http';
88
import StatsClient from '../metrics/StatsClient';
99
import { objectKeyByteLimit } from '../constants';
10+
const jsutil = require('../jsutil');
1011

1112
export type CallApiMethod = (
1213
methodName: string,
@@ -409,14 +410,15 @@ function retrieveData(
409410
return eachSeries(locations,
410411
(current, next) => data.get(current, response, log,
411412
(err: any, readable: http.IncomingMessage) => {
413+
const cbOnce = jsutil.once(next);
412414
// NB: readable is of IncomingMessage type
413415
if (err) {
414416
log.error('failed to get object', {
415417
error: err,
416418
method: 'retrieveData',
417419
});
418420
_destroyResponse();
419-
return next(err);
421+
return cbOnce(err);
420422
}
421423
// response.isclosed is set by the S3 server. Might happen if
422424
// the S3-client closes the connection before the first request
@@ -430,19 +432,19 @@ function retrieveData(
430432
// @ts-ignore
431433
responseErr.code = 'ResponseError';
432434
responseErr.message = 'response closed by client request before all data sent';
433-
return next(responseErr);
435+
return cbOnce(responseErr);
434436
}
435437
// readable stream successfully consumed
436438
readable.on('end', () => {
437439
currentStream = null;
438440
log.debug('readable stream end reached');
439-
return next();
441+
return cbOnce();
440442
});
441443
// errors on server side with readable stream
442444
readable.on('error', err => {
443445
log.error('error piping data from source');
444446
_destroyResponse();
445-
return next(err);
447+
return cbOnce(err);
446448
});
447449
currentStream = readable;
448450
return readable.pipe(response, { end: false });

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"engines": {
44
"node": ">=16"
55
},
6-
"version": "8.1.64",
6+
"version": "8.1.65",
77
"description": "Common utilities for the S3 project components",
88
"main": "build/index.js",
99
"repository": {

0 commit comments

Comments
 (0)