Won't the fact that `ensureHelper` also calls itself complicate this somewhat, see https://github.com/mozilla/pdf.js/blob/master/src/core/pdf_manager.js#L186.