fix(plugins): document leaked promise limitation on hook timeout

Add a code comment explaining that timed-out handler promises continue
running in the background since the current plugin hook API does not
accept an AbortSignal for cooperative cancellation. Notes the path
forward for when the plugin contract evolves.
This commit is contained in:
Jerry-Xin 2026-03-17 14:08:32 +08:00
parent 20615bbb13
commit 3d5b7a4a80

View File

@ -175,6 +175,12 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp
/**
* Execute a single async handler with the configured timeout.
* Throws on timeout; callers catch via handleHookError.
*
* NOTE: On timeout, the underlying handler promise is NOT cancelled it
* continues running in the background until it settles. The current plugin
* hook contract (`() => Promise<T>`) does not accept an `AbortSignal`, so
* cooperative cancellation is not yet possible. If the plugin API evolves
* to accept a signal, wire it through here for proper cleanup.
*/
async function callHandlerWithTimeout<T>(
fn: () => Promise<T>,