ChiriVulpes / scryfall-sdk

A Node.js SDK for https://scryfall.com/docs/api, written in TypeScript.
MIT License
99 stars 16 forks source link

this._listeners[eventName] is not iterable #72

Closed forsureitsme closed 2 months ago

forsureitsme commented 4 months ago

Probably related: #70

Stumbled upon this using the following code:

error: Uncaught (in promise) TypeError: this._listeners[eventName] is not iterable
    at MagicEmitter.emit (file:///workspaces/d8d099a1fadaa81c6e599ecfe83d9f469250a38764467e176adbf0728d8d99f2/node_modules/.deno/scryfall-sdk@4.2.2/node_modules/scryfall-sdk/out/util/EventEmitter.js:70:47)
    at MagicEmitter.emit (file:///workspaces/d8d099a1fadaa81c6e599ecfe83d9f469250a38764467e176adbf0728d8d99f2/node_modules/.deno/scryfall-sdk@4.2.2/node_modules/scryfall-sdk/out/util/MagicEmitter.js:51:22)
    at file:///workspaces/d8d099a1fadaa81c6e599ecfe83d9f469250a38764467e176adbf0728d8d99f2/node_modules/.deno/scryfall-sdk@4.2.2/node_modules/scryfall-sdk/out/api/Cards.js:433:35
    at eventLoopTick (ext:core/01_core.js:168:7)
for await (
  const card of Scry.Cards.search("t:basic", {
    unique: "art",
    order: "released",
    dir: "desc",
  }).all()
) {
  // Omitted irrelevant part
}

After some debugging it looks like it runs throught all of the entries before crashing. I suppose this is not intended because the example on using MagicEmitters's .all() doesn't warn about needing to handle this.

ChiriVulpes commented 4 months ago

Sorry, a bit busy with other stuff this week, I'll look into this soon. Thanks for the bug report!

ChiriVulpes commented 2 months ago

So sorry it took me long to get to this, turns out I think somehow I managed to publish old code twice, meaning 4.2.2, 4.2.1, and 4.2.0 were all functionally identical, ie without the fix in #70. The code appears to be correct now in 5.0.0, that I've just published. (For unrelated reasons.)

forsureitsme commented 2 months ago

There's no need to be sorry, you don't owe us your time. Thank you.