Addendum to #3607 - protect against js errors