Skip to content

Commit 866f94e

Browse files
committed
fixup! util: add getActiveResources
1 parent 5cd12af commit 866f94e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/node_process_methods.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef int mode_t;
3636
namespace node {
3737

3838
using v8::ApiObject;
39+
using v8::Array;
3940
using v8::ArrayBuffer;
4041
using v8::BackingStore;
4142
using v8::CFunction;
@@ -254,7 +255,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
254255
Environment* env = Environment::GetCurrent(args);
255256

256257
Local<Context> ctx = env->context();
257-
Local<Object> return_obj = Object::New(args.GetIsolate());
258+
Local<Array> return_array = Array::New(args.GetIsolate());
258259

259260
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
260261
AsyncWrap* w = req_wrap->GetAsyncWrap();
@@ -263,12 +264,12 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
263264
double async_id = w->get_async_id();
264265
Local<Object> req_obj = w->object();
265266

266-
USE(return_obj->Set(ctx,
267-
Number::New(args.GetIsolate(), async_id),
268-
req_obj));
267+
USE(return_array->Set(ctx,
268+
Number::New(args.GetIsolate(), async_id),
269+
req_obj));
269270
}
270271

271-
args.GetReturnValue().Set(return_obj);
272+
args.GetReturnValue().Set(return_array);
272273
}
273274

274275
// Non-static, friend of HandleWrap. Could have been a HandleWrap method but
@@ -277,19 +278,19 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
277278
Environment* env = Environment::GetCurrent(args);
278279

279280
Local<Context> ctx = env->context();
280-
Local<Object> return_obj = Object::New(args.GetIsolate());
281+
Local<Array> return_array = Array::New(args.GetIsolate());
281282

282283
for (auto w : *env->handle_wrap_queue()) {
283284
if (w->persistent().IsEmpty() || !HandleWrap::HasRef(w))
284285
continue;
285286
double async_id = w->get_async_id();
286287
Local<Object> handle_object = w->object();
287-
USE(return_obj->Set(ctx, Number::New(args.GetIsolate(),
288-
async_id),
289-
handle_object));
288+
USE(return_array->Set(ctx, Number::New(args.GetIsolate(),
289+
async_id),
290+
handle_object));
290291
}
291292

292-
args.GetReturnValue().Set(return_obj);
293+
args.GetReturnValue().Set(return_array);
293294
}
294295

295296
static void ResourceUsage(const FunctionCallbackInfo<Value>& args) {

0 commit comments

Comments
 (0)