Skip to content

Commit

Permalink
fixed restarts caused by 404s of unexpected http verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
ritch committed Nov 29, 2012
1 parent 8ab4b2d commit fc4ae32
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## 0.6.9

- Fixed bug where `internal-client` was not accessible from modules
- Fixed bug where `internal-client` was not accessible from modules
- Fixed restarts caused by 404s of unexpected http verbs

## 0.6.8

Expand Down
3 changes: 2 additions & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var db = require('./db')
, escapeRegExp = /[\-\[\]{}()+?.,\\\^$|#\s]/g
, debug = require('debug')('router')
, doh = require('doh')
, error404 = doh.createResponder()
, async = require('async');

/**
Expand Down Expand Up @@ -83,7 +84,7 @@ Router.prototype.route = function (req, res) {
} else {
debug('404 %s', req.url);
res.statusCode = 404;
res.domain.emit('error', new Error('Resource not found'));
error404({message: 'resource not found'}, req, res);
}
});
});
Expand Down
1 change: 1 addition & 0 deletions test-app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script>mocha.setup('bdd')</script>
<!-- -- tests -- -->
<script src="test/util.test.js"></script>
<script src="test/misc.test.js"></script>
<script src="test/collection.test.js"></script>
<script src="test/user-collection.test.js"></script>
</head>
Expand Down
17 changes: 17 additions & 0 deletions test-app/public/test/misc.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('404s', function(){
it('should not prevent a server from responding', function(done) {
this.timeout(5000);

var tests = 50;
var remaining = tests;

while(tests--) {
dpd('/').post({foo: 'bar'}, function (res, err) {
remaining--;
if(!remaining) {
done();
}
});
}
});
});

0 comments on commit fc4ae32

Please sign in to comment.