Skip to content

Commit

Permalink
Add comments explaing the breaking change in Node.js between v10 and v12
Browse files Browse the repository at this point in the history
  • Loading branch information
bryaningl3 committed May 18, 2021
1 parent e59d40e commit 2720860
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions timing/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ module.exports = (() => {
const wrappedAction = () => {
const disposable = this._timeoutBindings[token];

// 2021/05/18, BRI. Invoking dispose cases the clearTimeout function to run.
// Running clearTimeout should not be necessary because the timer has elapsed
// and the callback is being invoked. However, failing to call clearTimeout in
// a Node.js environment (after version 10) leads to a memory leak. Notice that
// this function has a reference to the Scheduler instance (via closure). In my
// view, this is breaking change between versions 10 and 12 of Node.js. I have
// been unable to locate any documentation regarding this change; however, a changes
// to did occur (which becomes obvious when inspecting the data structure returned by
// the setTimeout function).

if (disposable) {
disposable.dispose();
}
Expand Down

0 comments on commit 2720860

Please sign in to comment.