Version
v24.14.1
v25.8.1
Platform
Linux <hostname> 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC <date> x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
const test = require("node:test")
test.mock.timers.enable()
let timeout = setTimeout(() => {}, 10)
const stack = new DisposableStack()
stack.use(timeout)
Here, timeout should be a Timeout object, but lacks to [Symbol.dispose] property. stack.use(...) fails with TypeError: Symbol(Symbol.dispose) is not a function.
How often does it reproduce? Is there a required condition?
Triggers always when:
- MockTimers are enabled,
- code under test uses
setTimeout with using or other explicit resource management features.
What is the expected behavior? Why is that the expected behavior?
Timeout objects produced by MockTimers should implement the API as documented in Node's documentation, i.e. the objects should have the [Symbol.dispose] property, and calling its function should cancel the timeout.
The [Symbol.dispose] property is part of a stable API.
What do you see instead?
const test = require("node:test")
let timeout1 = setTimeout(()=>{})
test.mock.timers.enable()
let timeout2 = setTimeout(()=>{})
Symbol.dispose in timeout1 //=> true
Symbol.dispose in timeout2 //=> false
Additional information
As an aside, timeout.close() is missing as well. While the documentation rightfully labels it as legacy, it is far from deprecated and should be supported by MockTimers.
Version
v24.14.1
v25.8.1
Platform
Subsystem
No response
What steps will reproduce the bug?
Here,
timeoutshould be aTimeoutobject, but lacks to[Symbol.dispose]property.stack.use(...)fails withTypeError: Symbol(Symbol.dispose) is not a function.How often does it reproduce? Is there a required condition?
Triggers always when:
setTimeoutwithusingor other explicit resource management features.What is the expected behavior? Why is that the expected behavior?
Timeoutobjects produced by MockTimers should implement the API as documented in Node's documentation, i.e. the objects should have the[Symbol.dispose]property, and calling its function should cancel the timeout.The
[Symbol.dispose]property is part of a stable API.What do you see instead?
Additional information
As an aside,
timeout.close()is missing as well. While the documentation rightfully labels it as legacy, it is far from deprecated and should be supported by MockTimers.