Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

tooltip race condition. throws TypeError: Cannot read property 'css' of null #4757

@brenovieira

Description

@brenovieira

Tooltip directive has a race condition on this line and this line.

If you have two tooltips and hover from one element to another a few times you will see the error.

I've created this plunker.

And attached these two screenshots to show you the error:

captura de tela 2015-10-28 as 02 13 50
captura de tela 2015-10-28 as 09 38 48

I tested with tooltip and tooltip-html and both have the same issue.

var tooltip;
...
if (!tooltip || !tooltip.html()) { return; }
if (!positionTimeout) {
   positionTimeout = $timeout(function() {
      // Reset the positioning.
      tooltip.css({ top: 0, left: 0 }); // throws TypeError
...

You're checking tooltip is null or undefined and setting a timeout, but if before the timeout triggers, removeTooltip() is called, you set tooltip = null; here and the exception occurs after timeout triggers.

It doesn't break the ui, but I've setted $exceptionhandler in my app to send me an email with the error, and I'm getting this error a lot (like 50 times yesterday), so I think it happens quite frequently in a normal use case with "common users".

A "double-checked locking" would solve the error, I mean, just check if (!tooltip || !tooltip.html()) { return; } again inside the timeout, before set position.

If you agree, I can open a PR with this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions