Heroku issue with NodeMailer - node.js

I am having an issue with Nodemailer on Heroku and I would really appreciate your help.
A previous version of my application used to work on Heroku with no problem and when I roll back to that version, it still works fine. In the latest version of the application, I have made no changes to the code accesses Nodemailer so this doesn't really make sense to me.
The version of nodemailer is: 0.6.5
Here is the log message:
2015-02-18T04:29:57.730815+00:00 app[web.2]: POST /employer/53f44e3df4f8150200554eb7/job/ 200 32ms - 581b
2015-02-18T04:29:58.045066+00:00 app[web.2]: /app/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:918
2015-02-18T04:29:58.045069+00:00 app[web.2]: this._xoauth2.reconnectCount = 0;
2015-02-18T04:29:58.045070+00:00 app[web.2]: ^
2015-02-18T04:29:58.041300+00:00 app[web.2]: Exit callback being invoked
2015-02-18T04:29:58.045072+00:00 app[web.2]: TypeError: Cannot assign to read only property 'reconnectCount' of false
2015-02-18T04:29:58.045073+00:00 app[web.2]: at SMTPClient._actionAUTHComplete (/app/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:918:34)
2015-02-18T04:29:58.045075+00:00 app[web.2]: at SMTPClient._onData (/app/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:352:29)
2015-02-18T04:29:58.045076+00:00 app[web.2]: at TLSSocket.emit (events.js:107:17)
2015-02-18T04:29:58.045078+00:00 app[web.2]: at readableAddChunk (_stream_readable.js:163:16)
2015-02-18T04:29:58.045079+00:00 app[web.2]: at TLSSocket.Readable.push (_stream_readable.js:126:10)
2015-02-18T04:29:58.045080+00:00 app[web.2]: at TCP.onread (net.js:529:20)
2015-02-18T04:29:58.769185+00:00 heroku[web.2]: Process exited with status 1
2015-02-18T04:29:58.780771+00:00 heroku[web.2]: State changed from up to crashed
2015-02-18T04:29:58.780771+00:00 heroku[web.2]: State changed from crashed to starting
2015-02-18T04:30:00.371578+00:00 heroku[web.2]: Starting process with command `node app.js`
2015-02-18T04:30:01.904015+00:00 app[web.2]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-02-18T04:30:01.904115+00:00 app[web.2]: Recommending WEB_CONCURRENCY=1
2015-02-18T04:30:02.288471+00:00 app[web.2]: Failed to load c++ bson extension, using pure JS version
2015-02-18T04:30:02.652326+00:00 app[web.2]: Started in PROD mode
2015-02-18T04:30:02.815284+00:00 app[web.2]: Express server listening on port 9622
2015-02-18T04:30:03.291115+00:00 heroku[web.2]: State changed from starting to up
We can see that it is failing on line 918 of 'client.js' with the error of:
TypeError: Cannot assign to read only property 'reconnectCount' of false.
Why would it be trying to assign 'false' to 'reconnectCount'?
My code is really simple:
app.locals.smtpTransport = nodemailer.createTransport('SMTP', {
service: 'Gmail',
auth: {
user: "example#gmail.com",
pass: "pass123"
}
});
I then use the code to send mail like:
req.app.locals.smtpTransport.sendMail( ......
This code works on my staging instance of Heroku so that doesn't make sense to me.
I have logged a support request with Heroku and any guidance that you can provide I will pass onto them.
Thanks so much for your help.

I just got the following response back from Nodemailer:
You are probably running Nodemailer in iojs. Only the latest version of Nodemailer is suported in node 0.12 and iojs, so you should either upgrade or fix the line 918 yourself like this:
if(this._xoauth2){
this._xoauth2.reconnectCount = 0;
}
Setting properties to boolean values was allowed in ES5 but iojs runs ES6 and trying to set a property in ES6 strict mode throws an error.
I think I have fixed this by by explicitly setting the node.js version in my package file to an older version that uses ES5.
This has fixed my problem. Lesson learned is to always set the nodejs version in the package file otherwise Heroku uses the latest version and it may be incompatible with your modules.
Many thanks to Nodemailer, they got back to me super quick with a great response.
Hopefully this will help someone else.
Thanks.

I'm working with meteor on an ubuntu install and I was getting similar errors after upgrading to Node.js v12.0 and installing Meteor's accounts-password module.
Turned out, since Meteor has not yet begun development on compatibility with Node.js v12.0, the new binaries installed with Node on my server were not compatible with the binaries bundled with my deployment so I was getting similar errors. In this case, the problem was not with Nodemailer but with simplesmtp.
As suggested here, the solution was to remove the bundled version and use npm to install a server-local version.
So in my deployment script, I added the following lines after I built the bundle.
cd bundle/programs/server/
sudo rm -R ./npm/npm-bcrypt/node_modules/bcrypt
sudo npm install bcrypt
sudo rm -R ./npm/email/node_modules/simplesmtp
sudo npm install simplesmtp
This is easier than modifying the source, especially if you have a scripted deployment.

Related

**ERROR! Callback called multiple times** JHipster version 7.3.1 (latest) having Error in Node

I have used other versions of JHipster but that one in my mac is not working fine, I am trying to generate a simple gateway (no entities yet), and after executing:
$jhipster
Filling the application metadata, I just got:
ERROR! Callback called multiple times
Error [ERR_MULTIPLE_CALLBACK]: Callback called multiple times
at NodeError (node:internal/errors:371:5)
at onFinish (node:internal/streams/writable:667:37)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:526:9)
at processTimers (node:internal/timers:500:7) {
code: 'ERR_MULTIPLE_CALLBACK'
So, according to #MattRaible and #GaelMariou, when having the ERROR! Callback called multiple times when generating JHipter applications or entities, you should verify the Node JS version. That version is provided in pom.xml or build.gradle, however, I never found a reference of node version in pom.xml (I use maven).
It is not clear where to get the exact version, nevertheless there is this article that states the same problem using node.js version bigger than 14: https://github.com/jhipster/generator-jhipster/issues/16744.
Meaning you should keep your node.js in version 14 until they solve that issue. I changed to v14.18.1, and now it is working sharp.

Hello Folks: I am having problem in starting sails app in nodejs. can anyone put forth their insights on that?

I tried running the latest version of node and postgresql, but was having problem i deprecated node to 13.12.0 and sails-postgresql to 1.0.2 as mentioned in one of the blog. still the error is coming. Stack trace is as below:
sails lift
info: Starting app...
(node:10460) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
info: Initializing apianalytics hook... (requests to monitored routes will be logged!)
info: ·• Auto-migrating... (alter)
info: Hold tight, this could take a moment.
error:
error: Error: Sails is taking too long to load.
Troubleshooting tips:
-• Were you still reading/responding to an interactive prompt?
(Whoops, sorry! Please lift again and try to respond a bit more quickly.)
-• Do you have a lot of stuff in assets/? Grunt might still be running.
(Try increasing the hook timeout. Currently it is 40000.
e.g. sails lift --hookTimeout=80000)
-• Is blueprints a custom or 3rd party hook?
(If initialize() is using a callback, make sure it's being called.)
at Timeout.tooLong [as _onTimeout] (C:\Users\dearm\OneDrive\Desktop\my work\sails-logrocket\myapp\node_modules\sails\lib\app\private\loadHooks.js:191:21)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
error: Could not load Sails app.
error:
error: Tips:
error: • First, take a look at the error message above.
error: • Make sure you've installed dependencies with npm install.
error: • Check that this app was built for a compatible version of Sails.
error: • Have a question or need help? (http://sailsjs.com/support)
complete code is here https://github.com/mannawar/sails_app
Try using Node version 10 and sails-postgresql version 2.0.0

Sailsjs: Server crash after using create blueprint with mongodb

I configured the connections.js file in config. I used shortcut route to check whether data is getting stored in the database.
I put the url localhost:1337/test/create?name=hello
It creates an entry in the database but server crashes with this log
process.nextTick(function() { throw err; });
^
TypeError: Right-hand side of 'instanceof' is not callable
at _hasBinary (/usr/local/lib/node_modules/sails/node_modules/has-binary/index.js:31:30)
at hasBinary (/usr/local/lib/node_modules/sails/node_modules/has-binary/index.js:58:10)
at Namespace.emit (/usr/local/lib/node_modules/sails/node_modules/socket.io/lib/namespace.js:214:9)
at Object.broadcastToRoom [as broadcast] (/usr/local/lib/node_modules/sails/node_modules/sails-hook-sockets/lib/sails.sockets/broadcast-to-room.js:74:13)
at child.broadcast (/usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:139:23)
at child.publishCreateSingle (/usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:1218:14)
at /usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:1069:16
at arrayEach (/usr/local/lib/node_modules/sails/node_modules/#sailshq/lodash/lib/index.js:1439:13)
at Function.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/#sailshq/lodash/lib/index.js:3500:13)
at child.publishCreate (/usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:1068:11)
at child.wrapper [as publishCreate] (/usr/local/lib/node_modules/sails/node_modules/#sailshq/lodash/lib/index.js:3250:19)
at created (/usr/local/lib/node_modules/sails/lib/hooks/blueprints/actions/create.js:48:19)
at wrapper (/usr/local/lib/node_modules/sails/node_modules/lodash/index.js:3592:19)
at applyInOriginalCtx (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:324:18)
at success (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
at _switch (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:58:28)
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:248:9
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:52:16
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:269:32
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:44:16
at child.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:152:44)
Update:20-Dec-2017..
This is what i had gotten when in installed the >sails-mongo adapter...What exactly is the version 2.1.20 of..?
Faizaans-MacBook-Pro:foobar faiz$ npm install sails-mongo --save
npm WARN deprecated mongodb#2.1.20: Please upgrade to 2.2.19 or higher
+ sails-mongo#0.12.2
added 14 packages in 7.967s
I couldn't figure out the exact issue here. I tried to connect my project to mysql and the same issue came up. The problem got solved when I created a new project and tried connecting it to the database.

Fresh meteor 1.3 on win7 not runnning

I am also posting this on stackoverflow as this is suggested by meteor itself :)
I upgraded my meteor project to Meteor 1.3, and after updating all the proper packages I could not get meteor 1.3 to run. Then I created a fresh project and still get this error I posted below. I also tried to create the simple-todos example shown here https://www.meteor.com/tutorials/blaze/creating-an-app in CMD. Same result.
Windows 7 btw :) Also I have not installed meteorhacks:npm or any other extra packages whatsoever.
http.js:733
throw new TypeError('The header content contains invalid characters');
^
TypeError: The header content contains invalid characters
at ClientRequest.OutgoingMessage.setHeader (http.js:733:13)
at new ClientRequest (http.js:1429:14)
at Object.exports.request (http.js:1899:10)
at Array.stream [as 3] (C:\Users\Lightspeed\AppData\Local\.meteor\packages\meteor-tool\1.3.0_3\mt-os.windows.x86_32\dev_bundle\lib\node_modules\http-proxy\lib\http-proxy\passes\web-incoming.js:108:74)
at ProxyServer.<anonymous> (C:\Users\Lightspeed\AppData\Local\.meteor\packages\meteor-tool\1.3.0_3\mt-os.windows.x86_32\dev_bundle\lib\node_modules\http-proxy\lib\http-proxy\index.js:80:21)
at Proxy._tryHandleConnections (C:\tools\runners\run-proxy.js:182:20)
at Server.<anonymous> (C:\tools\runners\run-proxy.js:50:12)
at Server.emit (events.js:98:17)
at HTTPParser.parser.onIncoming (http.js:2164:12)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:152:23)
at Socket.socket.ondata (http.js:2022:22)
at TCP.onread (net.js:528:27)
Meteor does startup properly and does not crash until I actually navigate to localhost:3000. The page immediately errors (host not reachable) and meteor crashes with the error shown in my OP.
This problem was related to a specific windows 7 version. Though I don't have specifics anymore, it has been resolved.

error when starting the server with grunt or node server

I am trying to use the mean stack as described here : http://mean.io/
after install, when making "grunt", there is an error :
debugger listening on port 5858
4 Jan 01:47:40 - [nodemon] reading ignore list
Express app started on port 3000
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
4 Jan 01:47:40 - [nodemon] app crashed - waiting for file changes before starting...
I tried the troubleshooting as specified on the site : Updating Grunt, bower and cleaning npm and bower caches worked well. but updating npm gives an error too:
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
This looks like a conflict between homebrew and npm.
but anyway i have version 1.3.21 installed.
There is the same error when i am trying node server.
do you have an idea on what i can do to make the server work ?
It may be too easy, but seems like your MongoDB server is not actually running. After having installed Mongo (on your Mac, I assume?), you have to open a Terminal window/tab, run mongod and leave it running (or use screen, etc.). You can try to access MongoDB CLI by typing mongo to make sure the server is running.
#desgnl: if you don't want to run mongod command everytime you are running the grunt, you can always use third party services like MongoDB Hosting: Database-as-a-Service by MongoLab https://mongolab.com Hope this helps too!

Resources