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