[Bug report] Unreachable code after return in bluebird dependency triggers multiple warnings

edited October 23, 2024
Hi! I'm contributing to the Cita extension (https://github.com/diegodlh/zotero-cita) and in this context, we rely on Zotero translators to import an item's references into Zotero.

Our code uses a Search translator and calls `getTranslators()` multiple times. Every single time, the Toolbox console prints two `unreachable code after return statement` warnings that quickly clutter the console. The warnings were initially pointing to https://github.com/zotero/zotero/blob/19977c69c4b53a0792ba57e25d3f8ffb1037b237/chrome/content/zotero/xpcom/translation/translate_firefox.js#L423, but it turns out that the offending line is in the bluebird dependency, specifically https://github.com/petkaantonov/bluebird/blob/df70847b651c7fdc46f774dc6ab5e709d7e005f3/src/util.js#L216. This was fixed in this commit: https://github.com/petkaantonov/bluebird/commit/6c8c069c34829557abfaca66d7f22383b389a4b5 back in 2020, but no releases were made since then...

I'm not sure why, but it might be useful to know that this happens when calling `getTranslators()` with a `{ DOI: string }` object given in `setSearch()`, and the code being "evaluated" in translate_firefox.js only seems to lead to bluebird's unreachable return when the EIDR.js translators is being processed (because that's what printing `code` shows).

TL/DR; If bluebird is no longer needed, you could consider removing the dependency. Otherwise, pointing to that more recent commit would help. As a last resort, maybe that translator needs fixing, but it seems ok at first glance.

Thanks in advance and I hope this report will help you!
  • It was Lulu.js, not EIDR.js. Fixed now — thanks. Your Zotero should auto-update within a few minutes.
  • Poor bluebird, so it was just by chance that I happened upon an unrelated piece of unreachable code! Thank you so much for fixing this.
Sign In or Register to comment.