Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,21 @@ void AsyncWrap::PopAsyncIds(const FunctionCallbackInfo<Value>& args) {
void AsyncWrap::AsyncReset(const FunctionCallbackInfo<Value>& args) {
AsyncWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
double execution_async_id = args[0]->IsNumber() ? args[0]->NumberValue() : -1;
double execution_async_id =
args[0]->IsNumber()
? args[0]
->NumberValue(args.GetIsolate()->GetCurrentContext())
.ToChecked()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… args[0].As<Number>()->Value() …?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

: -1;
wrap->AsyncReset(execution_async_id);
}


void AsyncWrap::QueueDestroyAsyncId(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsNumber());
AsyncWrap::EmitDestroy(
Environment::GetCurrent(args), args[0]->NumberValue());
Environment::GetCurrent(args),
args[0]->NumberValue(args.GetIsolate()->GetCurrentContext()).ToChecked());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We skip validation of the argument in JS land when async hooks checks are disabled – so we probably don’t want ToChecked()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, dunno. There's literally a CHECK above, so I thought ToChecked would work here. I mean, it might still crash, sure, but nowhere it didn't crash earlier.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, I missed that – in that case, we don’t need NumberValue() either and can cast via .As<Number>(), right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P You're right. Updating the PR.

}

void AsyncWrap::AddWrapMethods(Environment* env,
Expand Down