mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
parent
75e0c7a2c9
commit
631ada0c64
|
|
@ -1,3 +1,8 @@
|
||||||
|
unreleased
|
||||||
|
==========
|
||||||
|
|
||||||
|
* Fix hanging on large stack of sync routes
|
||||||
|
|
||||||
4.18.0 / 2022-04-25
|
4.18.0 / 2022-04-25
|
||||||
===================
|
===================
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,14 +279,14 @@ proto.handle = function handle(req, res, out) {
|
||||||
// this should be done for the layer
|
// this should be done for the layer
|
||||||
self.process_params(layer, paramcalled, req, res, function (err) {
|
self.process_params(layer, paramcalled, req, res, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(layerError || err);
|
next(layerError || err)
|
||||||
|
} else if (route) {
|
||||||
|
layer.handle_request(req, res, next)
|
||||||
|
} else {
|
||||||
|
trim_prefix(layer, layerError, layerPath, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route) {
|
sync = 0
|
||||||
return layer.handle_request(req, res, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
trim_prefix(layer, layerError, layerPath, path);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,8 +327,6 @@ proto.handle = function handle(req, res, out) {
|
||||||
} else {
|
} else {
|
||||||
layer.handle_request(req, res, next);
|
layer.handle_request(req, res, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
sync = 0
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,23 @@ describe('Router', function(){
|
||||||
router.handle({ url: '/', method: 'GET' }, { end: done });
|
router.handle({ url: '/', method: 'GET' }, { end: done });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not stack overflow with a large sync stack', function (done) {
|
it('should not stack overflow with a large sync route stack', function (done) {
|
||||||
|
this.timeout(5000) // long-running test
|
||||||
|
|
||||||
|
var router = new Router()
|
||||||
|
|
||||||
|
for (var i = 0; i < 6000; i++) {
|
||||||
|
router.get('/foo', function (req, res, next) { next() })
|
||||||
|
}
|
||||||
|
|
||||||
|
router.get('/foo', function (req, res) {
|
||||||
|
res.end()
|
||||||
|
})
|
||||||
|
|
||||||
|
router.handle({ url: '/foo', method: 'GET' }, { end: done })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should not stack overflow with a large sync middleware stack', function (done) {
|
||||||
this.timeout(5000) // long-running test
|
this.timeout(5000) // long-running test
|
||||||
|
|
||||||
var router = new Router()
|
var router = new Router()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user