@@ -258,21 +258,6 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
258
258
Array::New (env->isolate (), request_v.data (), request_v.size ()));
259
259
}
260
260
261
- static void GetActiveRequestsInfo (const FunctionCallbackInfo<Value>& args) {
262
- Environment* env = Environment::GetCurrent (args);
263
-
264
- std::vector<Local<Value>> requests_info;
265
- for (ReqWrapBase* req_wrap : *env->req_wrap_queue ()) {
266
- AsyncWrap* w = req_wrap->GetAsyncWrap ();
267
- if (w->persistent ().IsEmpty ()) continue ;
268
- requests_info.emplace_back (OneByteString (env->isolate (),
269
- w->MemoryInfoName ().c_str ()));
270
- }
271
-
272
- args.GetReturnValue ().Set (
273
- Array::New (env->isolate (), requests_info.data (), requests_info.size ()));
274
- }
275
-
276
261
// Non-static, friend of HandleWrap. Could have been a HandleWrap method but
277
262
// implemented here for consistency with GetActiveRequests().
278
263
void GetActiveHandles (const FunctionCallbackInfo<Value>& args) {
@@ -288,18 +273,37 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
288
273
Array::New (env->isolate (), handle_v.data (), handle_v.size ()));
289
274
}
290
275
291
- void GetActiveHandlesInfo (const FunctionCallbackInfo<Value>& args) {
276
+ static void GetActiveResourcesInfo (const FunctionCallbackInfo<Value>& args) {
292
277
Environment* env = Environment::GetCurrent (args);
278
+ std::vector<Local<Value>> resources_info;
279
+
280
+ // Active requests
281
+ for (ReqWrapBase* req_wrap : *env->req_wrap_queue ()) {
282
+ AsyncWrap* w = req_wrap->GetAsyncWrap ();
283
+ if (w->persistent ().IsEmpty ()) continue ;
284
+ resources_info.emplace_back (
285
+ OneByteString (env->isolate (), w->MemoryInfoName ().c_str ()));
286
+ }
293
287
294
- std::vector<Local<Value>> handles_info;
288
+ // Active handles
295
289
for (HandleWrap* w : *env->handle_wrap_queue ()) {
296
290
if (w->persistent ().IsEmpty () || !HandleWrap::HasRef (w)) continue ;
297
- handles_info .emplace_back (OneByteString (env-> isolate (),
298
- w->MemoryInfoName ().c_str ()));
291
+ resources_info .emplace_back (
292
+ OneByteString (env-> isolate (), w->MemoryInfoName ().c_str ()));
299
293
}
300
294
295
+ // Active timeouts
296
+ resources_info.insert (resources_info.end (),
297
+ env->timeout_info ()[0 ],
298
+ OneByteString (env->isolate (), " Timeout" ));
299
+
300
+ // Active immediates
301
+ resources_info.insert (resources_info.end (),
302
+ env->immediate_info ()->ref_count (),
303
+ OneByteString (env->isolate (), " Immediate" ));
304
+
301
305
args.GetReturnValue ().Set (
302
- Array::New (env->isolate (), handles_info .data (), handles_info .size ()));
306
+ Array::New (env->isolate (), resources_info .data (), resources_info .size ()));
303
307
}
304
308
305
309
static void ResourceUsage (const FunctionCallbackInfo<Value>& args) {
@@ -578,10 +582,9 @@ static void Initialize(Local<Object> target,
578
582
SetMethod (context, target, " resourceUsage" , ResourceUsage);
579
583
580
584
SetMethod (context, target, " _debugEnd" , DebugEnd);
581
- SetMethod (context, target, " _getActiveRequestsInfo" , GetActiveRequestsInfo);
582
585
SetMethod (context, target, " _getActiveRequests" , GetActiveRequests);
583
586
SetMethod (context, target, " _getActiveHandles" , GetActiveHandles);
584
- SetMethod (context, target, " _getActiveHandlesInfo " , GetActiveHandlesInfo );
587
+ SetMethod (context, target, " getActiveResourcesInfo " , GetActiveResourcesInfo );
585
588
SetMethod (context, target, " _kill" , Kill);
586
589
SetMethod (context, target, " _rawDebug" , RawDebug);
587
590
@@ -609,9 +612,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
609
612
registry->Register (ResourceUsage);
610
613
611
614
registry->Register (GetActiveRequests);
612
- registry->Register (GetActiveRequestsInfo);
613
615
registry->Register (GetActiveHandles);
614
- registry->Register (GetActiveHandlesInfo );
616
+ registry->Register (GetActiveResourcesInfo );
615
617
registry->Register (Kill);
616
618
617
619
registry->Register (Cwd);
0 commit comments