checkSyncHash static method

void checkSyncHash(
  1. String name,
  2. String instead
)

warn when a sync Hash method (name, like Hash.make) runs in the web server. instead is the method to use.

Implementation

static void checkSyncHash(String name, String instead) {
  try {
    if (!Dox().isWebServer) return;
    String site = _callSite(StackTrace.current);
    if (!_hashSites.add(site)) return;
    _warn(
      '$name ran in the web server at $site. It blocks the isolate while '
      'bcrypt runs, so other requests wait. Use await $instead(...) '
      'instead.',
    );
  } catch (_) {
    // a warning must never break the request
  }
}