File tree 2 files changed +4
-6
lines changed
test/node-api/test_worker_terminate_finalization 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -225,9 +225,10 @@ class RefBase : protected Finalizer, RefTracker {
225
225
// from one of Unwrap or napi_delete_reference.
226
226
//
227
227
// When it is called from Unwrap or napi_delete_reference we only
228
- // want to do the delete if the finalizer has already run or
229
- // cannot have been queued to run (ie the reference count is > 0),
228
+ // want to do the delete if there is no finalizer or the finalizer has already
229
+ // run or cannot have been queued to run (i.e. the reference count is > 0),
230
230
// otherwise we may crash when the finalizer does run.
231
+ //
231
232
// If the finalizer may have been queued and has not already run
232
233
// delay the delete until the finalizer runs by not doing the delete
233
234
// and setting _delete_self to true so that the finalizer will
@@ -239,6 +240,7 @@ class RefBase : protected Finalizer, RefTracker {
239
240
static inline void Delete (RefBase* reference) {
240
241
reference->Unlink ();
241
242
if ((reference->RefCount () != 0 ) ||
243
+ (reference->_finalize_callback == nullptr ) ||
242
244
(reference->_delete_self ) ||
243
245
(reference->_finalize_ran )) {
244
246
delete reference;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
const common = require ( '../../common' ) ;
3
3
4
- // TODO(addaleax): Run this test once it stops failing under ASAN/valgrind.
5
- // Refs: https://github.com/nodejs/node/issues/34731
6
- common . skip ( 'Reference management in N-API leaks memory' ) ;
7
-
8
4
const { Worker, isMainThread } = require ( 'worker_threads' ) ;
9
5
10
6
if ( isMainThread ) {
You can’t perform that action at this time.
0 commit comments