Skip to content

Commit

Permalink
src: create handle scope in FastInternalModuleStat
Browse files Browse the repository at this point in the history
It needs a handle scope for the context handle. Since the
FastApiCallbackOptions struct doesn't have isolate on it
in V8 12.4 on Node.js 22, use Isolate::TryGetCurrent() to
get to the isolate needed for the handle scope creation and
fallback to the slow callback if no isolate is entered.

PR-URL: #54384
Refs: #52797
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and RafaelGSS committed Sep 6, 2024
1 parent 99e5abc commit 5c9599a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,14 @@ static int32_t FastInternalModuleStat(
const FastOneByteString& input,
// NOLINTNEXTLINE(runtime/references) This is V8 api.
FastApiCallbackOptions& options) {
// This needs a HandleScope which needs an isolate.
Isolate* isolate = Isolate::TryGetCurrent();
if (!isolate) {
options.fallback = true;
return -1;
}

HandleScope scope(isolate);
Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());

auto path = std::filesystem::path(input.data, input.data + input.length);
Expand Down

0 comments on commit 5c9599a

Please sign in to comment.