js: Fix deadlock between addUri and openpage

Fixes #2120