Environment
- hookable: v6.1.1
- Node.js: v22
- Browser: Chrome / any Chromium browser
Reproduction
import { Hookable, createDebugger } from 'hookable'
const hooks = new Hookable()
createDebugger(hooks, { inspect: true })
await hooks.callHook('myHook') // timer started, never ended
await hooks.callHook('myHook') // browser warns: "Timer 'myHook' already exists"
Describe the bug
When inspect: true (the default in browsers), createDebugger calls
console.timeLog() in the afterEach handler but never calls
console.timeEnd(). The timer started by console.time() in beforeEach
leaks on every hook call.
On the second call to the same hook the browser warns:
Timer 'hookName' already exists
Root cause: in src/debugger.ts lines 69-72, console.timeEnd() is
inside the else branch of the inspect check, so it is never reached
when inspect: true.
Since inspect defaults to true in browsers, every browser user of
createDebugger is affected.
I have a fix ready and would like to submit a PR if confirmed.
Additional context
No response
Logs
Environment
Reproduction
import { Hookable, createDebugger } from 'hookable'
const hooks = new Hookable()
createDebugger(hooks, { inspect: true })
await hooks.callHook('myHook') // timer started, never ended
await hooks.callHook('myHook') // browser warns: "Timer 'myHook' already exists"
Describe the bug
When
inspect: true(the default in browsers),createDebuggercallsconsole.timeLog()in theafterEachhandler but never callsconsole.timeEnd(). The timer started byconsole.time()inbeforeEachleaks on every hook call.
On the second call to the same hook the browser warns:
Root cause: in
src/debugger.tslines 69-72,console.timeEnd()isinside the
elsebranch of theinspectcheck, so it is never reachedwhen
inspect: true.Since
inspectdefaults totruein browsers, every browser user ofcreateDebuggeris affected.I have a fix ready and would like to submit a PR if confirmed.
Additional context
No response
Logs