This is a synchronous callback -- the chrome browser api is likely async, which changes the order of code execution.
We make this mistake a lot in our code, but consider wrapping this in a setTimeout(..., 0)