Skip to content

Commit

Permalink
Merge pull request #36 from bsyk/patch-1
Browse files Browse the repository at this point in the history
Set timeout error code to 504
  • Loading branch information
dvonlehman committed Sep 6, 2018
2 parents e87fc14 + 7b17370 commit 75d1c3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ module.exports = function(options) {
function unhandledApiError(err, next) {
debug('unhandled API error: %s', err.code);
if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
return next(Error.http(408, 'API call timed out'));
return next(Error.http(504, 'API call timed out'));
}
return next(err);
}
Expand Down
4 changes: 2 additions & 2 deletions test/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ describe('timeout', function() {
.end(done);
});

it('api timeout returns 408', function(done) {
it('api timeout returns 504', function(done) {
this.apiLatency = 50;
this.proxyOptions.timeout = 20;

supertest(this.server)
.get('/proxy')
.expect(408, done);
.expect(504, done);
});

it('api returns 408 when instructed to cache', function(done) {
Expand Down

0 comments on commit 75d1c3e

Please sign in to comment.