Skip to content

Commit 06d995e

Browse files
committed
Try fixing bugs with Node 12 and 13
1 parent d00b101 commit 06d995e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/node/async_context_releaser.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ void AsyncContextReleaser::Execute(Napi::Env env) {
2828
}
2929

3030
AsyncContextReleaser* AsyncContextReleaser::GetDefault() {
31+
if (!_default) {
32+
Napi::HandleScope scope(constructor().Env());
33+
auto object = constructor().New({});
34+
_default = Unwrap(object);
35+
_default->Ref();
36+
}
3137
return _default;
3238
}
3339

3440
void AsyncContextReleaser::Init(Napi::Env env, Napi::Object) {
3541
auto func = DefineClass(env, "AsyncContextReleaser", {});
3642
constructor() = Napi::Persistent(func);
3743
constructor().SuppressDestruct();
38-
auto object = constructor().New({});
39-
_default = Unwrap(object);
40-
_default->Ref();
4144
}
4245

4346
} // namespace node_webrtc

0 commit comments

Comments
 (0)