Fixed bugs in async processing of JavaScript layer