Skip to content

Commit c881895

Browse files
committed
add test of saving 256MB JSON traces
1 parent 571fa6b commit c881895

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lighthouse-core/test/lib/asset-saver-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,26 @@ describe('asset-saver helper', () => {
155155
assert.deepStrictEqual(JSON.parse(traceFileContents), trace);
156156
});
157157
});
158+
159+
it('can save traces over 256MB', () => {
160+
// Create a trace that wil be longer than 256MB when stringified, the hard
161+
// limit of a string in v8.
162+
// https://mobile.twitter.com/bmeurer/status/879276976523157505
163+
const baseEventsLength = JSON.stringify(traceEvents).length;
164+
const countNeeded = Math.ceil(Math.pow(2, 28) / baseEventsLength);
165+
let longTraceEvents = [];
166+
for (let i = 0; i < countNeeded; i++) {
167+
longTraceEvents = longTraceEvents.concat(traceEvents);
168+
}
169+
const trace = {
170+
traceEvents: longTraceEvents
171+
};
172+
173+
return assetSaver.saveTrace(trace, traceFilename)
174+
.then(_ => {
175+
const fileStats = fs.lstatSync(traceFilename);
176+
assert.ok(fileStats.size > Math.pow(2, 28));
177+
});
178+
});
158179
});
159180
});

0 commit comments

Comments
 (0)