From 1eaf899252f7e1fb06b64f378843428a3bd66be7 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Mon, 10 Apr 2017 14:28:21 +0200 Subject: [PATCH] don't save handleIds for node --- lib/common/timers.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/common/timers.ts b/lib/common/timers.ts index 3861f6684..97e4f3dd5 100644 --- a/lib/common/timers.ts +++ b/lib/common/timers.ts @@ -27,17 +27,28 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam try { task.invoke.apply(this, arguments); } finally { - delete tasksByHandleId[data.handleId]; + if (typeof data.handleId === 'number') { + // Node returns complex objects as handleIds + delete tasksByHandleId[data.handleId]; + } } }; data.args[0] = timer; data.handleId = setNative.apply(window, data.args); - tasksByHandleId[data.handleId] = task; + if (typeof data.handleId === 'number') { + // Node returns complex objects as handleIds -> no need to keep them around. Additionally, + // this throws an + // exception in older node versions and has no effect there, because of the stringified key. + tasksByHandleId[data.handleId] = task; + } return task; } function clearTask(task: Task) { - delete tasksByHandleId[(task.data).handleId]; + if (typeof(task.data).handleId === 'number') { + // Node returns complex objects as handleIds + delete tasksByHandleId[(task.data).handleId]; + } return clearNative((task.data).handleId); }