Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/ARSN-376/probe' into w/7.…
Browse files Browse the repository at this point in the history
…70/bugfix/ARSN-376/probe
  • Loading branch information
nicolas2bert committed Dec 1, 2023
2 parents 29ef2ef + 0624405 commit a99a6d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
8 changes: 1 addition & 7 deletions lib/network/probe/ProbeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ export class ProbeServer extends httpServer {
return;
}

const probeResponse = this._handlers.get(req.url!)!(res, log);
if (probeResponse !== undefined && probeResponse !== '') {
// Return an internal error with the response
errors.InternalError
.customizeDescription(probeResponse)
.writeResponse(res);
}
this._handlers.get(req.url!)!(res, log);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"engines": {
"node": ">=16"
},
"version": "7.70.13",
"version": "7.70.14",
"description": "Common utilities for the S3 project components",
"main": "build/index.js",
"repository": {
Expand Down
28 changes: 23 additions & 5 deletions tests/unit/network/probe/ProbeServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,34 @@ describe('network.probe.ProbeServer', () => {
});

it('500 response on bad probe', done => {
server.addHandler('/check', () => 'check failed');
const failedMessage = 'failed_message';
server.addHandler('/check', res => {
res.writeHead(500);
res.end(failedMessage);
});
makeRequest('GET', '/check', (err, res) => {
assert.ifError(err);
assert.strictEqual(res.statusCode, 500);
res.setEncoding('utf8');
res.on('data', body => {
assert.strictEqual(body, failedMessage);
done();
});
});
});

it('500 response on bad async probe', done => {
const failedMessage = 'failed_message';
server.addHandler('/check', async res => {
res.writeHead(500);
res.end(failedMessage);
});
makeRequest('GET', '/check', (err, res) => {
assert.ifError(err);
assert.strictEqual(res.statusCode, 500);
res.setEncoding('utf8');
res.on('data', body => {
assert.strictEqual(
body,
'{"errorType":"InternalError","errorMessage":"check failed"}',
);
assert.strictEqual(body, failedMessage);
done();
});
});
Expand Down

0 comments on commit a99a6d9

Please sign in to comment.