File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,11 @@ Environment::~Environment() {
276
276
TRACE_EVENT_NESTABLE_ASYNC_END0 (
277
277
TRACING_CATEGORY_NODE1 (environment), " Environment" , this );
278
278
279
+ // Do not unload addons on the main thread. Some addons need to retain memory
280
+ // beyond the Environment's lifetime, and unloading them early would break
281
+ // them; with Worker threads, we have the opportunity to be stricter.
282
+ // Also, since the main thread usually stops just before the process exits,
283
+ // this is far less relevant here.
279
284
if (!is_main_thread ()) {
280
285
// Dereference all addons that were loaded into this environment.
281
286
for (binding::DLib& addon : loaded_addons_) {
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ void Initialize(Local<Object> exports,
49
49
// the Environment instance has been destroyed.
50
50
static uv_async_t extra_async;
51
51
uv_loop_t * loop = node::GetCurrentEventLoop (context->GetIsolate ());
52
- uv_async_init (loop, &extra_async, [](uv_async_t *) {});
52
+ int err = uv_async_init (loop, &extra_async, [](uv_async_t *) {});
53
+ assert (err == 0 );
53
54
uv_unref (reinterpret_cast <uv_handle_t *>(&extra_async));
54
55
}
55
56
}
You can’t perform that action at this time.
0 commit comments