Skip to content

Commit

Permalink
return the promise returned by then to guarantee order
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Nov 29, 2022
1 parent 175a5a9 commit fdc9086
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/browser/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,9 @@ Instrumenter.prototype.instrumentNetwork = function() {
metadata.stack = (new Error()).stack;
}

var promise = orig.apply(this, args);

// Start our handler before returning the promise. This allows resp.clone()
// to execute before other handlers touch the response.
promise.then(function (resp) {
return orig.apply(this, args).then(function (resp) {
metadata.end_time_ms = _.now();
metadata.status_code = resp.status;
metadata.response_content_type = resp.headers.get('Content-Type');
Expand Down Expand Up @@ -427,7 +425,6 @@ Instrumenter.prototype.instrumentNetwork = function() {
self.errorOnHttpStatus(metadata);
return resp;
});
return promise;
};
}, this.replacements, 'network');
}
Expand Down

0 comments on commit fdc9086

Please sign in to comment.