Skip to content

Commit 8634293

Browse files
committed
Use the 'request' event instead of calling the first event handler directly
1 parent 8e87e27 commit 8634293

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ proto.use = function use(route, fn) {
9494

9595
// wrap vanilla http.Servers
9696
if (handle instanceof http.Server) {
97-
handle = handle.listeners('request')[0];
97+
var server = handle;
98+
handle = function (req, res, next) {
99+
server.once('request', function () {
100+
next();
101+
});
102+
server.emit('request', req, res);
103+
};
98104
}
99105

100106
// strip trailing slash

0 commit comments

Comments
 (0)