File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -155,5 +155,26 @@ describe('asset-saver helper', () => {
155
155
assert . deepStrictEqual ( JSON . parse ( traceFileContents ) , trace ) ;
156
156
} ) ;
157
157
} ) ;
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
+ } ) ;
158
179
} ) ;
159
180
} ) ;
You can’t perform that action at this time.
0 commit comments