How to debug a scroll block in JavaScript

I’m using scrollIntoView(), but the behaviour is the same for scrollTo(...) and even location = '#....

When I use a timeout > 500ms for the scrolling action it works. How can I debug this? Something must be interfering with the programmatic scrolling.

PS: When clicking a button which has as href #..., the scrolling works also. Somehow, the user event goes through without the need for a timeout.