Skip to content

Commit 5c9599a

Browse files
joyeecheungRafaelGSS
authored andcommitted
src: create handle scope in FastInternalModuleStat
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 <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 99e5abc commit 5c9599a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/node_file.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,14 @@ static int32_t FastInternalModuleStat(
10511051
const FastOneByteString& input,
10521052
// NOLINTNEXTLINE(runtime/references) This is V8 api.
10531053
FastApiCallbackOptions& options) {
1054+
// This needs a HandleScope which needs an isolate.
1055+
Isolate* isolate = Isolate::TryGetCurrent();
1056+
if (!isolate) {
1057+
options.fallback = true;
1058+
return -1;
1059+
}
1060+
1061+
HandleScope scope(isolate);
10541062
Environment* env = Environment::GetCurrent(recv->GetCreationContextChecked());
10551063

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

0 commit comments

Comments
 (0)