Skip to content

Commit

Permalink
Tweaks to debug logged bundle adds (only new unique content is logged)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jan 28, 2025
1 parent 1e86bca commit 66f17ff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/CodeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ class CodeManager {
for(let b of buckets) {
this._initBucket(pageUrl, b);

let debugLoggedContent = codeContent.join("\n");
debug("Adding code to bundle %o for %o (bucket: %o, size: %o): %o", this.name, pageUrl, b, debugLoggedContent.length, debugLoggedContent.length > DEBUG_LOG_TRUNCATION_SIZE ? debugLoggedContent.slice(0, DEBUG_LOG_TRUNCATION_SIZE) + "…" : debugLoggedContent);
for(let content of codeContent) {
if(content) {
this.pages[pageUrl][b].add(content);
if(!this.pages[pageUrl][b].has(content)) {
debug("Adding code to bundle %o for %o (bucket: %o, size: %o): %o", this.name, pageUrl, b, content.length, content.length > DEBUG_LOG_TRUNCATION_SIZE ? content.slice(0, DEBUG_LOG_TRUNCATION_SIZE) + "…" : content);
this.pages[pageUrl][b].add(content);
}
}
}
}
Expand Down Expand Up @@ -146,19 +147,21 @@ class CodeManager {

buckets = CodeManager.normalizeBuckets(buckets);

debug("Retrieving %o for %o (buckets: %o)", this.name, url, buckets);
let set = new Set();
let size = 0;
for(let b of buckets) {
if(!this.pages[url][b]) {
// Just continue, if you retrieve code from a bucket that doesn’t exist or has no code, it will return an empty set
continue;
}

for(let entry of this.pages[url][b]) {
size += entry.length;
set.add(entry);
}
}

debug("Retrieving %o for %o (buckets: %o, entries: %o, size: %o)", this.name, url, buckets, set.size, size);
return set;
}

Expand Down

0 comments on commit 66f17ff

Please sign in to comment.