How do I get the current node from a Block module?
The Book module implements a block that needs to access to the currently viewed node, and it uses the following code, in BookNavigationBlock::build().

if ($node = $this-&gt;requestStack-&gt;getCurrentRequest()-&gt;get('node')) {
  $current_bid = empty($node-&gt;book['bid']) ? 0 : $node-&gt;book['bid'];
}


$this-&gt;requestStack is initialized from the following code.

  public function __construct(array $configuration, $plugin_id, $plugin_definition, RequestStack $request_stack, BookManagerInterface $book_manager, EntityStorageInterface $node_storage) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);

    $this-&gt;requestStack = $request_stack;
    $this-&gt;bookManager = $book_manager;
    $this-&gt;nodeStorage = $node_storage;
  }

  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
    $configuration, 
    $plugin_id, 
    $plugin_definition, 
    $container-&gt;get('request_stack'), 
    $container-&gt;get('book.manager'), 
    $container-&gt;get('entity.manager')-&gt;getStorage('node')
    );
  }


The code is essentially like the one you are using, but it seems that in your case, a module is messing up with what $container-&gt;get('request_stack')-&gt;getCurrentRequest()-&gt;get('node') is returning. 

As workaround, if you find in which cases it happens, you could override BlockBase::blockAccess() to avoid your build() method is called in those cases.