checkHandler static method

void checkHandler(
  1. RouteData route,
  2. Duration took
)

warn when the sync part of the middleware and controller of route took longer than the limit

Implementation

static void checkHandler(RouteData route, Duration took) {
  if (took <= _limit) return;
  try {
    String name = '${route.method} ${route.path}';
    if (!_routes.add(name)) return;
    _warn(
      '$name blocked the isolate for ${took.inMilliseconds} ms (limit '
      '${_limit.inMilliseconds} ms). Other requests on this isolate had '
      'to wait. Move heavy CPU work (like bcrypt, PDF or image work) to '
      'await Dox().compute(...), and use Hash.makeAsync or '
      'Hash.verifyAsync for passwords.',
    );
  } catch (_) {
    // a warning must never break the request
  }
}