fix crash during JavaScript code emission