Why Drush cron go to view of nodes? i have a simple function to return 404 on some content-type

function module_type_node_view($node, $view_mode, $langcode) {
  // variables
  $type = $node['#node']-&gt;getType();
  $userRole = \Drupal::currentUser()-&gt;getRoles();
  // if is events2/subsidiary
  if(($type === 'events2' || $type === 'subsidiary') &amp;&amp;
  (in_array('anonymous', $userRole))) {
    throw new NotFoundHttpException();
  }
}


But if i run drush cron i have this error:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException:  in module_type_node_view() (


The crohn is performed anonymously, I have no way to create an exception
I'm going to assume there is something running with cron like a search indexer or something handling nodes, and since it is run anonymously, it triggers this.