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.

TypeError: source.on is not a function

See original GitHub issue

When trying to send a message I get an error: TypeError: source.on is not a function.

Version: 3.31.0

Code Snippet

twilio.messages.create({
    "to": "+18009876543", // I changed the phone number for this issue
    "from": "+18001234567", // I changed the phone number for this issue
    "body": "Hello World"
}).then((message) => resolve(message)).catch((error) => reject(error));

Exception/Log

TypeError: source.on is not a function
    at Function.DelayedStream.create (/Users/charliefish/Desktop/MyApp/node_modules/delayed-stream/lib/delayed_stream.js:33:10)
    at FormData.CombinedStream.append (/Users/charliefish/Desktop/MyApp/node_modules/combined-stream/lib/combined_stream.js:44:37)
    at FormData.append (/Users/charliefish/Desktop/MyApp/node_modules/form-data/lib/form_data.js:74:3)
    at appendFormValue (/Users/charliefish/Desktop/MyApp/node_modules/request/request.js:326:21)
    at Request.init (/Users/charliefish/Desktop/MyApp/node_modules/request/request.js:337:11)
    at new Request (/Users/charliefish/Desktop/MyApp/node_modules/request/request.js:127:8)
    at request (/Users/charliefish/Desktop/MyApp/node_modules/request/index.js:53:10)
    at RequestClient.request (/Users/charliefish/Desktop/MyApp/node_modules/twilio/lib/base/RequestClient.js:78:3)
    at Twilio.request (/Users/charliefish/Desktop/MyApp/node_modules/twilio/lib/rest/Twilio.js:241:26)
    at Api.Domain.request (/Users/charliefish/Desktop/MyApp/node_modules/twilio/lib/base/Domain.js:34:22)
    at V2010.Version.request (/Users/charliefish/Desktop/MyApp/node_modules/twilio/lib/base/Version.js:45:23)
    at V2010.Version.create (/Users/charliefish/Desktop/MyApp/node_modules/twilio/lib/base/Version.js:125:24)
    at Function.create (/Users/charliefish/Desktop/MyApp/node_modules/twilio/lib/rest/api/v2010/account/message.js:122:33)
    at Promise (/Users/charliefish/Desktop/MyApp/index.js:283:19)
    at new Promise (<anonymous>)
    at sendSMS (/Users/charliefish/Desktop/MyApp/index.js:270:9)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
fishcharliecommented, May 24, 2019

I just realized this occurs when the to property was set to an object. Seems like Twilio should still handle this error better and give a more descriptive error message.

0reactions
childish-sambinocommented, Nov 22, 2022

The error is now better surfaced after the migration to axios as the underlying request client in version 3.41.0: https://github.com/twilio/twilio-node/pull/542.

Closing as resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: source.on is not a function · Issue #2366 - GitHub
I'm trying to POST an array of values to a HTTP endpoint, and this is the error I receive: TypeError: source.on is not...
Read more >
Getting ERROR: uncaughtException: source.on is not a ...
When you call createFormData with myJson as parameter, you will see exception source.on is not a function ! And we keep thinking where...
Read more >
Error Received: Source.on is not a function - App Platform
Hello Team, I am trying to create a ticket in Freshdesk along with attachments, but I am getting an error. The Error is:...
Read more >
TypeError: source.on is not a function - Web Developer Forum
“TypeError: source.on is not a function” My complete code: I have an index.js file, created automatically, and not modified
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
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