Skip to content
This repository was archived by the owner on Apr 23, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/Http/HttpModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,15 @@ export default class HttpModule extends EventDispatcher {
// XMLHttpRequest, we must wait for another process tick to check for a refreshed list.
setTimeout((lastURLToken => {
return () => {
let resourceEntries = performance.getEntriesByType('resource');

// Check the timing entries for possible browser limit.
if( resourceEntries.length >= 150 ) {
console.warn('The browser Performance API may have exceeded its recommended limit of 150. See https://developer.mozilla.org/en-US/docs/Web/API/Performance/setResourceTimingBufferSize');
}

// Filter the timing entries to return only the one concerned by the last request made
let entries = performance.getEntriesByType('resource').filter(function(entry) {
let entries = resourceEntries.filter(function(entry) {
return ~entry.name.indexOf(lastURLToken);
});

Expand Down
5 changes: 5 additions & 0 deletions lib/Http/LatencyModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export default class LatencyModule extends HttpModule {
// With Resource Timing API
if (!xhr) {
this._getTimingEntry(entry => {
if( !entry ) {
console.warn(`Network JS could not find a performance entry for ${ this._lastURLToken }.`)
return
}

// The latency calculation differs between an HTTP and an HTTPS connection
// See: http://www.w3.org/TR/resource-timing/#processing-model
let latency = !entry.secureConnectionStart
Expand Down