Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 0d05123

Browse files
committed
timers: fix unref() memory leak
The destructor isn't being called for timers that have been unref'd. Fixes: #8364 Signed-off-by: Trevor Norris <trev.norris@gmail.com>
1 parent 3a08b7c commit 0d05123

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

icu_config.gypi

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Do not edit. Generated by the configure script.
2+
{ 'variables': { }}

lib/timers.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ var Timeout = function(after) {
290290
this._repeat = false;
291291
};
292292

293+
294+
function unrefdHandle() {
295+
this.owner._onTimeout();
296+
if (!this.owner.repeat)
297+
this.owner.close();
298+
}
299+
300+
293301
Timeout.prototype.unref = function() {
294302
if (!this._handle) {
295303

@@ -303,7 +311,8 @@ Timeout.prototype.unref = function() {
303311
if (delay < 0) delay = 0;
304312
exports.unenroll(this);
305313
this._handle = new Timer();
306-
this._handle.ontimeout = this._onTimeout;
314+
this._handle.owner = this;
315+
this._handle.ontimeout = unrefdHandle;
307316
this._handle.start(delay, 0);
308317
this._handle.domain = this.domain;
309318
this._handle.unref();

0 commit comments

Comments
 (0)