really wait for dequeue in javascript