Skip to content

Commit 5d8556a

Browse files
committed
fix: attach remaining non-enumerables to req
1 parent e1befaa commit 5d8556a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/client.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,19 +526,30 @@ extend(Raven.prototype, {
526526
* (eg. globalContext.request + domainContext.request + kwargs.request),
527527
* we manually pull them out from original objects.
528528
*
529+
* Same scenario happens when some frameworks (eg. Koa) decide to use request within
530+
* request. eg `this.request.req`, which adds aliases to the main `request` object.
531+
* By manually reassigning them here, we don't need to add additional checks
532+
* like `req.method || (req.req && req.req.method)`
533+
*
529534
* We don't use Object.assign/extend as it's only merging over objects own properties,
530535
* and we don't want to go through all of the properties as well, as we simply don't
531536
* need all of them.
532-
*
533-
* So far the only missing piece is `ip`, but we can specify what properties should
534-
* be pulled by extending `nonEnumerables` array.
535537
**/
536538
var sources = Array.from(arguments).filter(function(source) {
537539
return Object.prototype.toString.call(source) === '[object Object]';
538540
});
539541
sources = [{}].concat(sources);
540542
var request = extend.apply(null, sources);
541-
var nonEnumberables = ['ip'];
543+
var nonEnumberables = [
544+
'headers',
545+
'host',
546+
'ip',
547+
'method',
548+
'protocol',
549+
'query',
550+
'secure',
551+
'url'
552+
];
542553

543554
nonEnumberables.forEach(function(key) {
544555
sources.forEach(function(source) {

0 commit comments

Comments
 (0)