executeWithTimeout method

Future<HookResult> executeWithTimeout(
  1. HookType type,
  2. HookContext context,
  3. Duration timeout
)

Execute hooks with an overall timeout for the entire chain.

If the timeout is exceeded, returns HookAbort with a timeout message.

Implementation

Future<HookResult> executeWithTimeout(
  HookType type,
  HookContext context,
  Duration timeout,
) async {
  try {
    return await executeAsync(type, context).timeout(timeout);
  } on TimeoutException {
    return HookAbort(
      'Hook chain for $type timed out after $timeout',
      error: TimeoutException('Chain timeout', timeout),
    );
  }
}