@@ -18,6 +18,9 @@ if (typeof global.gc === 'function') {
18
18
19
19
function noop ( ) { }
20
20
21
+ const bootstrapIds = new Set ( ) ;
22
+ let firstTriggerAsyncId ;
23
+
21
24
class ActivityCollector {
22
25
constructor ( start , {
23
26
allowNoInit = false ,
@@ -61,6 +64,10 @@ class ActivityCollector {
61
64
this . _asyncHook . disable ( ) ;
62
65
}
63
66
67
+ get firstTriggerAsyncId ( ) {
68
+ return firstTriggerAsyncId ;
69
+ }
70
+
64
71
sanityCheck ( types ) {
65
72
if ( types != null && ! Array . isArray ( types ) ) types = [ types ] ;
66
73
@@ -177,7 +184,13 @@ class ActivityCollector {
177
184
return h ;
178
185
}
179
186
180
- _init ( uid , type , triggerAsyncId , handle ) {
187
+ _init ( uid , type , triggerAsyncId , handle , bootstrap ) {
188
+ if ( bootstrap ) {
189
+ bootstrapIds . add ( uid ) ;
190
+ return ;
191
+ } else if ( ! firstTriggerAsyncId ) {
192
+ firstTriggerAsyncId = triggerAsyncId ;
193
+ }
181
194
const activity = {
182
195
uid,
183
196
type,
@@ -190,38 +203,43 @@ class ActivityCollector {
190
203
this . _stamp ( activity , 'init' ) ;
191
204
this . _activities . set ( uid , activity ) ;
192
205
this . _maybeLog ( uid , type , 'init' ) ;
193
- this . oninit ( uid , type , triggerAsyncId , handle ) ;
206
+ this . oninit ( uid , type , triggerAsyncId , handle , bootstrap ) ;
194
207
}
195
208
196
209
_before ( uid ) {
210
+ if ( bootstrapIds . has ( uid ) ) return ;
197
211
const h = this . _getActivity ( uid , 'before' ) ;
198
212
this . _stamp ( h , 'before' ) ;
199
213
this . _maybeLog ( uid , h && h . type , 'before' ) ;
200
214
this . onbefore ( uid ) ;
201
215
}
202
216
203
217
_after ( uid ) {
218
+ if ( bootstrapIds . has ( uid ) ) return ;
204
219
const h = this . _getActivity ( uid , 'after' ) ;
205
220
this . _stamp ( h , 'after' ) ;
206
221
this . _maybeLog ( uid , h && h . type , 'after' ) ;
207
222
this . onafter ( uid ) ;
208
223
}
209
224
210
225
_destroy ( uid ) {
226
+ if ( bootstrapIds . has ( uid ) ) return ;
211
227
const h = this . _getActivity ( uid , 'destroy' ) ;
212
228
this . _stamp ( h , 'destroy' ) ;
213
229
this . _maybeLog ( uid , h && h . type , 'destroy' ) ;
214
230
this . ondestroy ( uid ) ;
215
231
}
216
232
217
233
_promiseResolve ( uid ) {
234
+ if ( bootstrapIds . has ( uid ) ) return ;
218
235
const h = this . _getActivity ( uid , 'promiseResolve' ) ;
219
236
this . _stamp ( h , 'promiseResolve' ) ;
220
237
this . _maybeLog ( uid , h && h . type , 'promiseResolve' ) ;
221
238
this . onpromiseResolve ( uid ) ;
222
239
}
223
240
224
241
_maybeLog ( uid , type , name ) {
242
+ if ( bootstrapIds . has ( uid ) ) return ;
225
243
if ( this . _logid &&
226
244
( type == null || this . _logtype == null || this . _logtype === type ) ) {
227
245
print ( `${ this . _logid } .${ name } .uid-${ uid } ` ) ;
0 commit comments