question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: TypeError: s is not iterable

See original GitHub issue

I am getting this error:

TypeError: s is not iterable
    at a (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:31148)
    at u (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:31423)
    at w (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:37337)
    at Object.t [as default] (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:37378)
    at e.<anonymous> (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:14352)
    at /Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:13146
    at Object.next (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:13251)
    at /Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:12163
    at new Promise (<anonymous>)
    at n (/Users/hervefulchiron/Downloads/GitHub/bee/node_modules/mailgun.js/dist/mailgun.js:2:11908)
error Command failed with exit code 1.

using:

"mailgun.js": "^3.4.0",

and this code:

const formData = require('form-data')
const Mailgun = require('mailgun.js')

const mailgun = new Mailgun(formData)
const mg = mailgun.client({
    username: 'api',
    key: '64xxxxxe66',
})

mg.messages.create('bitcoinvsalts.com', {
    from: "Excited User <mailgun@sandbox-123.mailgun.org>",
    to: ["herve@gmail.com"],
    subject: "Hello",
    text: "s fsfsdfsdfsf sd f"
})
.then( msg => {
    console.log("MAILGUN:", msg)
})
.catch( err => {
    console.log("MAILGUN ERROR:", err)
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
simeonpashleycommented, Sep 24, 2021

As much as I hate “me too”, it’s happening for me too! I tried your exact properties too.

“mailgun.js”: “3.5.9”, node: 14.17.6

With reference to others alleging “isomorphic-fetch” as a culprit, a quick look through my “yarn.lock” shows other packages have installed “node-fetch” too. My project itself does not include any versions of fetch.

FIX: pin the “node-fetch” version

  "resolutions": {
    "node-fetch": "3.0.0-beta.9"
  },

The clue came from @dsalcedo issue that showed the source-maps and “validateAndMerge”, which is part of “ky-universal” package. Following that down, it uses “node-fetch” with that version. I pinned my package version to the same one and it all works!

I would guess the issue is caused somewhere if “node-fetch” is in your project, either explicitly or implicitly through “isomorphic-fetch”

0reactions
wmertenscommented, Mar 9, 2022

Same issue here, indeed multiple node-fetch versions through transitive installation:

$ npm ls node-fetch
react-starter@0.0.0 /home/wmertens/Projects/canopy/react
+-- isomorphic-fetch@2.2.1
| `-- node-fetch@1.7.3 
`-- nodemailer-mailgun-transport@2.1.3
  `-- mailgun.js@3.7.3
    `-- ky-universal@0.8.2
      `-- node-fetch@3.0.0-beta.9 

fixed by installing isomorphic-fetch@3, even though oddly that still uses a separate node-fetch:

react-starter@0.0.0 /home/wmertens/Projects/canopy/react
+-- isomorphic-fetch@3.0.0
| `-- node-fetch@2.6.7
+-- nodemailer-mailgun-transport@2.1.3
| `-- mailgun.js@3.7.3
|   `-- ky-universal@0.8.2
|     `-- node-fetch@3.0.0-beta.9
`-- react-dom@15.7.0
  `-- fbjs@0.8.16
    `-- isomorphic-fetch@2.2.1
      `-- node-fetch@1.7.3

Maybe mailgun.js should require node-fetch as a peer dep

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are Objects not Iterable in JavaScript? - Stack Overflow
I tried the below code, but I get a TypeError: can't convert undefined to object . var example = {a: {e: 'one', f:...
Read more >
TypeError: 'x' is not iterable - JavaScript
The JavaScript exception "is not iterable" occurs when the value which is given as the right hand-side of for…of or as argument of...
Read more >
Error: TypeError: s is not iterable · Issue #159 - GitHub
This happens when the code is inside an async function (I'm testing in lambda function). async (data) => { const mg = new...
Read more >
TypeError: 'X' is not iterable in JavaScript | bobbyhadz
The "TypeError: 'X' is not iterable" occurs when using the for...of loop with a right-hand side value that is not iterable, e.g. an...
Read more >
Errors: Is Not Iterable - JavaScript - W3cubDocs
TypeError : 'x' is not iterable ... The JavaScript exception "is not iterable" occurs when the value which is given as the right-hand...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found