devslopes-learn / mac-chat-api

Prebuilt api for slack app clone.
83 stars 87 forks source link

error when I try to start the app from Heroku #28

Open dallli92 opened 5 years ago

dallli92 commented 5 years ago

Hello , please I need help , because I can go further in the Kotlin course, In fact, after I followed all the steps exactly as mentionned by JohnnyB, when I want to start the app in Heroku I get this erro , (I am using the free way, without a credit card )

Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail

sahilsaini65 commented 5 years ago

I am getting the same error too. The problem seems to be related to the URL starting with "mongodb+srv". Also, I am using Mongo DB Atlas for the database as we can no longer create a mongodb account..

smitaerande commented 4 years ago

Same error for me as well. Please help to resolve. Getting Application error after successful deployment.

duchuy-13 commented 4 years ago

hey, I just found a solution

update version your mongodb package on package.json "mongoose": "5.8.3", "passport-local-mongoose": "5.0.0", "mongodb-core": "3.2.7"

Also remember to add this ip config network access on your Mongo DB Atlas: "0.0.0.0/0". No special character (#,%...) on your account password for access database Deploy again and it will work perfectly.

arjavpatni commented 4 years ago

@duchuy-13 thanks man! This solves it.

wolfmoonhust commented 4 years ago

hello, i already updated mongodb version on package.json but it's still fail 2020-08-20T13:59:17.461350+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 2020-08-20T13:59:17.461506+00:00 app[web.1]: npm ERR! npm bugs slacky-slack 2020-08-20T13:59:17.461675+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 2020-08-20T13:59:17.461832+00:00 app[web.1]: npm ERR! npm owner ls slacky-slack 2020-08-20T13:59:17.461982+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 2020-08-20T13:59:17.465485+00:00 app[web.1]: 2020-08-20T13:59:17.465761+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 2020-08-20T13:59:17.465841+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2020-08-20T13:59:17.539236+00:00 heroku[web.1]: Process exited with status 1 2020-08-20T13:59:17.575353+00:00 heroku[web.1]: State changed from starting to crashed 2020-08-20T14:30:18.916030+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=wolfdevchat.herokuapp.com request_id=63128a80-79ec-4fb0-90a3-ee148ca6e8f0 fwd="42.114.34.254" dyno= connect= service= status=503 bytes= protocol=https 2020-08-20T14:30:19.556607+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=wolfdevchat.herokuapp.com request_id=84aafd67-4ea3-42a0-b2b3-8d02f7d4ce4d fwd="42.114.34.254" dyno= connect= service= status=503 bytes= protocol=https

Anyone knows how i can fix it? Thanks in advanced!

tromgy commented 4 years ago

@wolfmoonhust could you post the complete log?

SumukhaK commented 3 years ago

Hello, i updated package.json but i got build failed message on heroku with logs:

-----> Building on the Heroku-20 stack -----> Node.js app detected parse error: Expected separator between values at line 46, column 20 ! Unable to parse package.json -----> Build failed We're sorry this build is failing! You can troubleshoot common issues here: https://devcenter.heroku.com/articles/troubleshooting-node-deploys If you're stuck, please submit a ticket so we can help: https://help.heroku.com/ Love, Heroku ! Push rejected, failed to compile Node.js app. ! Push failed

my package.json :

{ "name": "slacky-slack", "version": "1.0.0", "type": "module", "engines": { "node": "6.10.2" }, "description": "Prebuilt api for slack app clone.", "main": "dist", "scripts": { "dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"", "build": "babel src -s -D -d dist --presets es2015,stage-0", "prestart": "npm run -s build", "start": "node ./dist/index.js", "lint": "eslint src", "test": "echo \"Error: no test specified\" && exit 1" }, "eslintConfig": { "parserOptions": { "ecmaVersion": 7, "sourceType": "module" }, "env": { "node": true }, "rules": { "no-console": 0, "no-unsed-vars": 1 } }, "author": "Jacob Luetzow", "license": "ISC", "dependencies": { "babel-cli": "6.24.1", "babel-core": "6.24.1", "babel-eslint": "7.2.3", "babel-preset-es2015": "6.24.1", "babel-preset-stage-0": "6.24.1", "body-parser": "1.17.1", "express": "4.15.2", "express-jwt": "5.3.0", "jsonwebtoken": "7.4.0", "mongoose": "5.8.3", "passport-local-mongoose": "5.0.0", "mongodb-core": "3.2.7", "passport-local": "1.0.0", "socket.io": "2.0.3", "uniq": "^1.0.1" }, "devDependencies": { "eslint": "3.19.0", "nodemon": "1.11.0" } }

tromgy commented 3 years ago

There are syntax errors in this JSON file, double quotes are not escaped on lines 11 and 16.

Line 11 should be:

    "dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"",

Line 16 should be:

    "test": "echo \"Error: no test specified\" && exit 1"
SumukhaK commented 3 years ago

Thanks i managed to build the app successfully but when I clicked on "Open App" it says Application error with the following tail log on my cli :

λ heroku logs --tail 2021-02-04T13:52:27.228690+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 2021-02-04T13:52:27.228895+00:00 app[web.1]: npm ERR! node v6.10.2 2021-02-04T13:52:27.229049+00:00 app[web.1]: npm ERR! npm v3.10.10 2021-02-04T13:52:27.229201+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-02-04T13:52:27.229324+00:00 app[web.1]: npm ERR! slacky-slack@1.0.0 start: node ./dist/index.js 2021-02-04T13:52:27.229538+00:00 app[web.1]: npm ERR! Exit status 1 2021-02-04T13:52:27.229664+00:00 app[web.1]: npm ERR! 2021-02-04T13:52:27.229773+00:00 app[web.1]: npm ERR! Failed at the slacky-slack@1.0.0 start script 'node ./dist/index.js'. 2021-02-04T13:52:27.229875+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed. 2021-02-04T13:52:27.229980+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the slacky-slack package, 2021-02-04T13:52:27.230079+00:00 app[web.1]: npm ERR! not with npm itself. 2021-02-04T13:52:27.230198+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 2021-02-04T13:52:27.230309+00:00 app[web.1]: npm ERR! node ./dist/index.js 2021-02-04T13:52:27.230410+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 2021-02-04T13:52:27.230514+00:00 app[web.1]: npm ERR! npm bugs slacky-slack 2021-02-04T13:52:27.230619+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 2021-02-04T13:52:27.230719+00:00 app[web.1]: npm ERR! npm owner ls slacky-slack 2021-02-04T13:52:27.230825+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 2021-02-04T13:52:27.233842+00:00 app[web.1]: 2021-02-04T13:52:27.234011+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 2021-02-04T13:52:27.234095+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2021-02-04T13:52:27.282287+00:00 heroku[web.1]: Process exited with status 1 2021-02-04T13:52:27.314683+00:00 heroku[web.1]: State changed from starting to crashed 2021-02-04T13:52:27.323457+00:00 heroku[web.1]: State changed from crashed to starting 2021-02-04T13:52:30.303194+00:00 heroku[web.1]: Starting process with command npm start 2021-02-04T13:52:34.364525+00:00 app[web.1]: 2021-02-04T13:52:34.364541+00:00 app[web.1]: > slacky-slack@1.0.0 prestart /app 2021-02-04T13:52:34.364542+00:00 app[web.1]: > npm run -s build 2021-02-04T13:52:34.364542+00:00 app[web.1]: 2021-02-04T13:52:37.278478+00:00 app[web.1]: src/config/index.js -> dist/config/index.js 2021-02-04T13:52:37.534507+00:00 app[web.1]: src/controller/account.js -> dist/controller/account.js 2021-02-04T13:52:37.691988+00:00 app[web.1]: src/controller/channel.js -> dist/controller/channel.js 2021-02-04T13:52:37.803946+00:00 app[web.1]: src/controller/extensions/userData-ext.js -> dist/controller/extensions/userData-ext.js 2021-02-04T13:52:38.005772+00:00 app[web.1]: src/controller/message.js -> dist/controller/message.js 2021-02-04T13:52:38.176920+00:00 app[web.1]: src/controller/user.js -> dist/controller/user.js 2021-02-04T13:52:38.216467+00:00 app[web.1]: src/db.js -> dist/db.js 2021-02-04T13:52:38.326426+00:00 app[web.1]: src/index.js -> dist/index.js 2021-02-04T13:52:38.357889+00:00 app[web.1]: src/middleware/authMiddleware.js -> dist/middleware/authMiddleware.js 2021-02-04T13:52:38.385047+00:00 app[web.1]: src/middleware/index.js -> dist/middleware/index.js 2021-02-04T13:52:38.411865+00:00 app[web.1]: src/model/account.js -> dist/model/account.js 2021-02-04T13:52:38.452260+00:00 app[web.1]: src/model/channel.js -> dist/model/channel.js 2021-02-04T13:52:38.519340+00:00 app[web.1]: src/model/message.js -> dist/model/message.js 2021-02-04T13:52:38.556744+00:00 app[web.1]: src/model/user.js -> dist/model/user.js 2021-02-04T13:52:38.590380+00:00 app[web.1]: src/routes/index.js -> dist/routes/index.js 2021-02-04T13:52:38.637536+00:00 app[web.1]: 2021-02-04T13:52:38.637538+00:00 app[web.1]: > slacky-slack@1.0.0 start /app 2021-02-04T13:52:38.637538+00:00 app[web.1]: > node ./dist/index.js 2021-02-04T13:52:38.637539+00:00 app[web.1]: 2021-02-04T13:52:39.821267+00:00 app[web.1]: 2021-02-04T13:52:39.821286+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:542 2021-02-04T13:52:39.821287+00:00 app[web.1]: throw new MongooseError('The uri parameter to openUri() must be a ' + 2021-02-04T13:52:39.821288+00:00 app[web.1]: ^ 2021-02-04T13:52:39.821782+00:00 app[web.1]: MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string. 2021-02-04T13:52:39.821784+00:00 app[web.1]: at Error.MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:10:11) 2021-02-04T13:52:39.821785+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:542:11) 2021-02-04T13:52:39.821785+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:332:15) 2021-02-04T13:52:39.821786+00:00 app[web.1]: at exports.default (/app/dist/db.js:24:22) 2021-02-04T13:52:39.821786+00:00 app[web.1]: at Object. (/app/dist/routes/index.js:44:18) 2021-02-04T13:52:39.821787+00:00 app[web.1]: at Module._compile (module.js:570:32) 2021-02-04T13:52:39.821787+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10) 2021-02-04T13:52:39.821788+00:00 app[web.1]: at Module.load (module.js:487:32) 2021-02-04T13:52:39.821788+00:00 app[web.1]: at tryModuleLoad (module.js:446:12) 2021-02-04T13:52:39.821789+00:00 app[web.1]: at Function.Module._load (module.js:438:3) 2021-02-04T13:52:39.821789+00:00 app[web.1]: at Module.require (module.js:497:17) 2021-02-04T13:52:39.821789+00:00 app[web.1]: at require (internal/module.js:20:19) 2021-02-04T13:52:39.821790+00:00 app[web.1]: at Object. (/app/dist/index.js:35:15) 2021-02-04T13:52:39.821790+00:00 app[web.1]: at Module._compile (module.js:570:32) 2021-02-04T13:52:39.821790+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10) 2021-02-04T13:52:39.821791+00:00 app[web.1]: at Module.load (module.js:487:32) 2021-02-04T13:52:39.833269+00:00 app[web.1]: 2021-02-04T13:52:39.845789+00:00 app[web.1]: npm ERR! Linux 4.4.0-1083-aws 2021-02-04T13:52:39.846321+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 2021-02-04T13:52:39.846744+00:00 app[web.1]: npm ERR! node v6.10.2 2021-02-04T13:52:39.847138+00:00 app[web.1]: npm ERR! npm v3.10.10 2021-02-04T13:52:39.847538+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-02-04T13:52:39.847832+00:00 app[web.1]: npm ERR! slacky-slack@1.0.0 start: node ./dist/index.js 2021-02-04T13:52:39.848121+00:00 app[web.1]: npm ERR! Exit status 1 2021-02-04T13:52:39.848260+00:00 app[web.1]: npm ERR! 2021-02-04T13:52:39.848379+00:00 app[web.1]: npm ERR! Failed at the slacky-slack@1.0.0 start script 'node ./dist/index.js'. 2021-02-04T13:52:39.848497+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed. 2021-02-04T13:52:39.848704+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the slacky-slack package, 2021-02-04T13:52:39.849022+00:00 app[web.1]: npm ERR! not with npm itself. 2021-02-04T13:52:39.849240+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 2021-02-04T13:52:39.849361+00:00 app[web.1]: npm ERR! node ./dist/index.js 2021-02-04T13:52:39.849483+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 2021-02-04T13:52:39.849599+00:00 app[web.1]: npm ERR! npm bugs slacky-slack 2021-02-04T13:52:39.849711+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 2021-02-04T13:52:39.849928+00:00 app[web.1]: npm ERR! npm owner ls slacky-slack 2021-02-04T13:52:39.850141+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 2021-02-04T13:52:39.862230+00:00 app[web.1]: 2021-02-04T13:52:39.862584+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 2021-02-04T13:52:39.862816+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2021-02-04T13:52:39.918589+00:00 heroku[web.1]: Process exited with status 1 2021-02-04T13:52:39.962463+00:00 heroku[web.1]: State changed from starting to crashed 2021-02-04T13:52:55.192766+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=a0dffe9e-4c42-4a2c-b4f1-3b620ad90cea fwd="103.146.224.147" dyno= connect= service= status=503 bytes= protocol=https 2021-02-04T13:52:56.220522+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokumongodbsmackchat.herokuapp.com request_id=26b0f875-76a4-4cd2-a611-ae581212f40a fwd="103.146.224.147" dyno= connect= service= status=503 bytes= protocol=https 2021-02-04T13:59:44.064494+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=9c80e443-c8f1-4cae-9394-97579e29807b fwd="103.146.224.150" dyno= connect= service= status=503 bytes= protocol=https 2021-02-04T13:59:44.777311+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokumongodbsmackchat.herokuapp.com request_id=58e42338-d08e-416f-93cb-8e3ea3f9f626 fwd="103.146.224.150" dyno= connect= service= status=503 bytes= protocol=https 2021-02-04T14:00:14.696174+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=22d48d73-540b-4138-830e-bcb94b2e226d fwd="103.146.224.150" dyno= connect= service= status=503 bytes= protocol=https 2021-02-04T14:00:16.698222+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokumongodbsmackchat.herokuapp.com request_id=596d9334-909d-46a8-b990-08f16717e66d fwd="103.146.224.150" dyno= connect= service= status=503 bytes= protocol=https

tromgy commented 3 years ago

I think your problem is this:

2021-02-04T13:52:39.821782+00:00 app[web.1]: MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string.

Make sure you supply the (correct) connection string to your MongoDB. Do a search for mongoUrl and see what it is being set to.

SumukhaK commented 3 years ago

While I seriously helping you trying to help me out, I got new error. I think this time it is saying my password have an un-escaped character ? I copy pasted auto generated password from atlas.

λ heroku logs --tail 2021-02-05T14:28:21.661117+00:00 app[web.1]: (node:38) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. 2021-02-05T14:28:21.809522+00:00 app[web.1]: Error: Password contains an illegal unescaped character 2021-02-05T14:28:21.809524+00:00 app[web.1]: at parseConnectionString (/app/node_modules/mongodb/lib/url_parser.js:299:13) 2021-02-05T14:28:21.809525+00:00 app[web.1]: at parseHandler (/app/node_modules/mongodb/lib/url_parser.js:130:14) 2021-02-05T14:28:21.809525+00:00 app[web.1]: at /app/node_modules/mongodb/lib/url_parser.js:114:7 2021-02-05T14:28:21.809526+00:00 app[web.1]: at QueryReqWrap.asyncCallback [as callback] (dns.js:62:16) 2021-02-05T14:28:21.809526+00:00 app[web.1]: at QueryReqWrap.onresolve [as oncomplete] (dns.js:218:10) 2021-02-05T14:28:21.858918+00:00 app[web.1]: 2021-02-05T14:28:21.875046+00:00 app[web.1]: npm ERR! Linux 4.4.0-1083-aws 2021-02-05T14:28:21.881490+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 2021-02-05T14:28:21.888666+00:00 app[web.1]: npm ERR! node v6.10.2 2021-02-05T14:28:21.889076+00:00 app[web.1]: npm ERR! npm v3.10.10 2021-02-05T14:28:21.889476+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-02-05T14:28:21.889788+00:00 app[web.1]: npm ERR! slacky-slack@1.0.0 start: node ./dist/index.js 2021-02-05T14:28:21.910676+00:00 app[web.1]: npm ERR! Exit status 1 2021-02-05T14:28:21.912843+00:00 app[web.1]: npm ERR! 2021-02-05T14:28:21.913104+00:00 app[web.1]: npm ERR! Failed at the slacky-slack@1.0.0 start script 'node ./dist/index.js'. 2021-02-05T14:28:21.913416+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed. 2021-02-05T14:28:21.913698+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the slacky-slack package, 2021-02-05T14:28:21.913960+00:00 app[web.1]: npm ERR! not with npm itself. 2021-02-05T14:28:21.914257+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 2021-02-05T14:28:21.914523+00:00 app[web.1]: npm ERR! node ./dist/index.js 2021-02-05T14:28:21.914785+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 2021-02-05T14:28:21.915041+00:00 app[web.1]: npm ERR! npm bugs slacky-slack 2021-02-05T14:28:21.915297+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 2021-02-05T14:28:21.915565+00:00 app[web.1]: npm ERR! npm owner ls slacky-slack 2021-02-05T14:28:21.915827+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 2021-02-05T14:28:21.921812+00:00 app[web.1]: 2021-02-05T14:28:21.922203+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 2021-02-05T14:28:21.922439+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2021-02-05T14:28:21.996150+00:00 heroku[web.1]: Process exited with status 1 2021-02-05T14:28:22.083470+00:00 heroku[web.1]: State changed from starting to crashed 2021-02-05T14:28:23.321870+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=09f9cd05-3920-443a-b073-fd7475d9a425 fwd="103.146.224.154" dyno= connect= service= status=503 bytes= protocol=https 2021-02-05T14:28:23.794308+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokumongodbsmackchat.herokuapp.com request_id=783f4e72-f518-40f7-a5dd-08a4797ae953 fwd="103.146.224.154" dyno= connect= service= status=503 bytes= protocol=https 2021-02-05T14:32:12.824640+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=b25bb365-32d8-45f6-873e-fbf768a57a3e fwd="103.146.224.159" dyno= connect= service= status=503 bytes= protocol=https 2021-02-05T14:32:13.349234+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokumongodbsmackchat.herokuapp.com request_id=3f62589a-bbf8-43ce-aabd-8e3a351f5cd2 fwd="103.146.224.159" dyno= connect= service= status=503 bytes= protocol=https 2021-02-05T14:33:17.000000+00:00 app[api]: Build started by user sumukh.aithal@gmail.com 2021-02-05T14:33:39.843453+00:00 app[api]: Release v5 created by user sumukh.aithal@gmail.com 2021-02-05T14:33:39.843453+00:00 app[api]: Deploy 1ed839f6 by user sumukh.aithal@gmail.com 2021-02-05T14:33:40.171619+00:00 heroku[web.1]: State changed from crashed to starting 2021-02-05T14:33:42.000000+00:00 app[api]: Build succeeded 2021-02-05T14:33:42.977629+00:00 heroku[web.1]: Starting process with command npm start 2021-02-05T14:33:46.355275+00:00 app[web.1]: 2021-02-05T14:33:46.355292+00:00 app[web.1]: > slacky-slack@1.0.0 prestart /app 2021-02-05T14:33:46.355293+00:00 app[web.1]: > npm run -s build 2021-02-05T14:33:46.355293+00:00 app[web.1]: 2021-02-05T14:33:47.939357+00:00 app[web.1]: src/config/index.js -> dist/config/index.js 2021-02-05T14:33:48.115720+00:00 app[web.1]: src/controller/account.js -> dist/controller/account.js 2021-02-05T14:33:48.240206+00:00 app[web.1]: src/controller/channel.js -> dist/controller/channel.js 2021-02-05T14:33:48.338785+00:00 app[web.1]: src/controller/extensions/userData-ext.js -> dist/controller/extensions/userData-ext.js 2021-02-05T14:33:48.547923+00:00 app[web.1]: src/controller/message.js -> dist/controller/message.js 2021-02-05T14:33:48.739342+00:00 app[web.1]: src/controller/user.js -> dist/controller/user.js 2021-02-05T14:33:48.783459+00:00 app[web.1]: src/db.js -> dist/db.js 2021-02-05T14:33:48.916429+00:00 app[web.1]: src/index.js -> dist/index.js 2021-02-05T14:33:48.949919+00:00 app[web.1]: src/middleware/authMiddleware.js -> dist/middleware/authMiddleware.js 2021-02-05T14:33:48.974158+00:00 app[web.1]: src/middleware/index.js -> dist/middleware/index.js 2021-02-05T14:33:48.998107+00:00 app[web.1]: src/model/account.js -> dist/model/account.js 2021-02-05T14:33:49.035096+00:00 app[web.1]: src/model/channel.js -> dist/model/channel.js 2021-02-05T14:33:49.102976+00:00 app[web.1]: src/model/message.js -> dist/model/message.js 2021-02-05T14:33:49.135309+00:00 app[web.1]: src/model/user.js -> dist/model/user.js 2021-02-05T14:33:49.185713+00:00 app[web.1]: src/routes/index.js -> dist/routes/index.js 2021-02-05T14:33:49.227709+00:00 app[web.1]: 2021-02-05T14:33:49.227712+00:00 app[web.1]: > slacky-slack@1.0.0 start /app 2021-02-05T14:33:49.227712+00:00 app[web.1]: > node ./dist/index.js 2021-02-05T14:33:49.227712+00:00 app[web.1]: 2021-02-05T14:33:50.193908+00:00 app[web.1]: Started on port 15604 2021-02-05T14:33:50.196016+00:00 app[web.1]: (node:38) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. 2021-02-05T14:33:50.206500+00:00 app[web.1]: Error: Password contains an illegal unescaped character 2021-02-05T14:33:50.206502+00:00 app[web.1]: at parseConnectionString (/app/node_modules/mongodb/lib/url_parser.js:299:13) 2021-02-05T14:33:50.206502+00:00 app[web.1]: at parseHandler (/app/node_modules/mongodb/lib/url_parser.js:130:14) 2021-02-05T14:33:50.206503+00:00 app[web.1]: at /app/node_modules/mongodb/lib/url_parser.js:114:7 2021-02-05T14:33:50.206503+00:00 app[web.1]: at QueryReqWrap.asyncCallback [as callback] (dns.js:62:16) 2021-02-05T14:33:50.206503+00:00 app[web.1]: at QueryReqWrap.onresolve [as oncomplete] (dns.js:218:10) 2021-02-05T14:33:50.214347+00:00 app[web.1]: 2021-02-05T14:33:50.223030+00:00 app[web.1]: npm ERR! Linux 4.4.0-1083-aws 2021-02-05T14:33:50.223435+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 2021-02-05T14:33:50.223793+00:00 app[web.1]: npm ERR! node v6.10.2 2021-02-05T14:33:50.224107+00:00 app[web.1]: npm ERR! npm v3.10.10 2021-02-05T14:33:50.224418+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-02-05T14:33:50.224666+00:00 app[web.1]: npm ERR! slacky-slack@1.0.0 start: node ./dist/index.js 2021-02-05T14:33:50.225055+00:00 app[web.1]: npm ERR! Exit status 1 2021-02-05T14:33:50.225295+00:00 app[web.1]: npm ERR! 2021-02-05T14:33:50.225530+00:00 app[web.1]: npm ERR! Failed at the slacky-slack@1.0.0 start script 'node ./dist/index.js'. 2021-02-05T14:33:50.225771+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed. 2021-02-05T14:33:50.226018+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the slacky-slack package, 2021-02-05T14:33:50.226515+00:00 app[web.1]: npm ERR! not with npm itself. 2021-02-05T14:33:50.226517+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 2021-02-05T14:33:50.226517+00:00 app[web.1]: npm ERR! node ./dist/index.js 2021-02-05T14:33:50.226701+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 2021-02-05T14:33:50.226843+00:00 app[web.1]: npm ERR! npm bugs slacky-slack 2021-02-05T14:33:50.227032+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 2021-02-05T14:33:50.227256+00:00 app[web.1]: npm ERR! npm owner ls slacky-slack 2021-02-05T14:33:50.227423+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 2021-02-05T14:33:50.231986+00:00 app[web.1]: 2021-02-05T14:33:50.232299+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 2021-02-05T14:33:50.232498+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2021-02-05T14:33:50.317111+00:00 heroku[web.1]: Process exited with status 1 2021-02-05T14:33:50.392380+00:00 heroku[web.1]: State changed from starting to crashed 2021-02-05T14:33:56.451600+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=0bc5caa0-942a-476a-8b40-c31df4e3d6fe fwd="103.146.224.154" dyno= connect= service= status=503 bytes= protocol=https 2021-02-05T14:33:56.970624+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokumongodbsmackchat.herokuapp.com request_id=6eb4ec22-f77c-4a3e-b7cc-83b51178e7e0 fwd="103.146.224.154" dyno= connect= service= status=503 bytes= protocol=https

tromgy commented 3 years ago

Just make sure that your connection string follows the format described here

There's a note about special characters.

SumukhaK commented 3 years ago

Hey, thanks a million. I did 2 changes and i honestly dont know which one fixed my issue. Change 1 : adding { useNewUrlParser: true },{ useMongoClient: true } in connect method.

mongoose.connect(config.mongoUrl, { useNewUrlParser: true },{ useMongoClient: true },function (err, database) { if (err) { console.log(err); process.exit(1); } console.log(config.mongoUrl); // Save database object from the callback for reuse. db = database; console.log("Database connection ready"); callback(db); });

change 2 : added ' ' to my password in my URL like this example (username and password are not mine, its some random sample text):

"mongoUrl": "mongodb+srv://imUser:'AbCd6Fc499Hi'>@mongodbtest.yxsef.mongodb.net/<database?retryWrites=true&w=majority",

SumukhaK commented 3 years ago

Well now i have a different problem altogether. i have my api url taken from heroku>settings>you app can be found at and hit it with register api via postman, only to get 404 in response and this is what heroku application log says:

at=info method=POST path="/v1/account/register" host=herokumongodbsmackchatterchat.herokuapp.com request_id=ad176ee8-bdbe-42a7-8efa-62999f65186c fwd="123.777.777.777" dyno=web.1 connect=0ms service=65ms status=404 bytes=403 protocol=https

tromgy commented 3 years ago

Something must be wrong with your Heroku settings. If you just go to the base url of your app in a browser, you should see this:

{"message":"Chat API is ALIVE!"}

but when I went to your base url: https://herokumongodbsmackchatterchat.herokuapp.com, I got 404 and a stock Heroku page "There's nothing here, yet"

I couldn't find anywhere in the chat API where it would respond with 404, so it must be some configuration issue with your Heroku account.

SumukhaK commented 3 years ago

You tried visiting the url i gave ? oops, I changed it thinking it may lead to some sort of security issues. This is my actual app URL : https://herokumongodbsmackchat.herokuapp.com/

and i do see this : {"message":"Chat API is ALIVE!"} but 404 on Postman when i try :

https://herokumongodbsmackchat.herokuapp.com/v1/account/register from the examples.

tromgy commented 3 years ago

Well, that one "is alive".

So are you saying the app is returning 404 only for the "register" endpoint?

SumukhaK commented 3 years ago

2 of the GET , 3 of the POST methods I tried met same fate. So i guess all of the API s ?!

tromgy commented 3 years ago

The only condition I can foresee wheree the '/' route is working, but the others do not, is some kind of mongodb connection problem.

Check your app log for "Database connection ready"

SumukhaK commented 3 years ago

Nope. I just checked. Here's what i have :

[import express from 'express'; import config from '../config'; import middleware from '../middleware'; import initalizeDb from '../db'; import user from '../controller/user'; import account from '../controller/account'; import channel from '../controller/channel'; import message from '../controller/message';

let router = express();

//connect to db initalizeDb(db => {

//internal middleware router.use(middleware({ config, db }));

//api routes v1 (/v1) router.use('/user', user({ config, db })); router.use('/account', account({ config, db })); router.use('/channel', channel({ config, db })); router.use('/message', message({ config, db })); });

export default router;](url)

tromgy commented 3 years ago

So I was able to reproduce 404 error when I put a simulated delay in the db connection. If mongoose.connect in db.js doesn't return (right away or ever?) you end up in a situation when only the '/' route will work and the others will return 404.

SumukhaK commented 3 years ago

Okay, but in Postman I get 404 even under 2 seconds

tromgy commented 3 years ago

So do you see "Database connection ready" in the log?

What matters is not how long it takes to respond to an HTTP request, but how long it takes to connect to mongodb.

If you don't see "Database connection ready", try your db connection string in Compass.

SumukhaK commented 3 years ago

I re-ran code after adding { useUnifiedTopology: true } to mongoose.connect only because it was suggested on the logs, and this is my heroku logs:

2021-02-06T21:14:53.000000+00:00 app[api]: Build started by user sumukh.abcd@gmail.com
2021-02-06T21:15:16.025214+00:00 heroku[web.1]: Restarting
2021-02-06T21:15:16.029708+00:00 heroku[web.1]: State changed from up to starting
2021-02-06T21:15:17.118022+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-02-06T21:15:15.859539+00:00 app[api]: Release v14 created by user sumukh.aithal@gmail.com
2021-02-06T21:15:17.266999+00:00 heroku[web.1]: Process exited with status 143
2021-02-06T21:15:15.859539+00:00 app[api]: Deploy 3ecf9a41 by user sumukh.abcd@gmail.com
2021-02-06T21:15:18.636106+00:00 heroku[web.1]: Starting process with command `npm start`
2021-02-06T21:15:18.000000+00:00 app[api]: Build succeeded
2021-02-06T21:15:21.619026+00:00 app[web.1]: 
2021-02-06T21:15:21.619054+00:00 app[web.1]: > slacky-slack@1.0.0 prestart /app
2021-02-06T21:15:21.619055+00:00 app[web.1]: > npm run -s build
2021-02-06T21:15:21.619055+00:00 app[web.1]: 
2021-02-06T21:15:23.620568+00:00 app[web.1]: src/config/index.js -> dist/config/index.js
2021-02-06T21:15:23.917274+00:00 app[web.1]: src/controller/account.js -> dist/controller/account.js
2021-02-06T21:15:24.044840+00:00 app[web.1]: src/controller/channel.js -> dist/controller/channel.js
2021-02-06T21:15:24.117714+00:00 app[web.1]: src/controller/extensions/userData-ext.js -> dist/controller/extensions/userData-ext.js
2021-02-06T21:15:24.296400+00:00 app[web.1]: src/controller/message.js -> dist/controller/message.js
2021-02-06T21:15:24.465160+00:00 app[web.1]: src/controller/user.js -> dist/controller/user.js
2021-02-06T21:15:24.519737+00:00 app[web.1]: src/db.js -> dist/db.js
2021-02-06T21:15:24.602766+00:00 app[web.1]: src/index.js -> dist/index.js
2021-02-06T21:15:24.630620+00:00 app[web.1]: src/middleware/authMiddleware.js -> dist/middleware/authMiddleware.js
2021-02-06T21:15:24.652663+00:00 app[web.1]: src/middleware/index.js -> dist/middleware/index.js
2021-02-06T21:15:24.677742+00:00 app[web.1]: src/model/account.js -> dist/model/account.js
2021-02-06T21:15:24.704034+00:00 app[web.1]: src/model/channel.js -> dist/model/channel.js
2021-02-06T21:15:24.752556+00:00 app[web.1]: src/model/message.js -> dist/model/message.js
2021-02-06T21:15:24.783717+00:00 app[web.1]: src/model/user.js -> dist/model/user.js
2021-02-06T21:15:24.828602+00:00 app[web.1]: src/routes/index.js -> dist/routes/index.js
2021-02-06T21:15:24.863164+00:00 app[web.1]: 
2021-02-06T21:15:24.863172+00:00 app[web.1]: > slacky-slack@1.0.0 start /app
2021-02-06T21:15:24.863173+00:00 app[web.1]: > node ./dist/index.js
2021-02-06T21:15:24.863173+00:00 app[web.1]: 
2021-02-06T21:15:26.271427+00:00 app[web.1]: Started on port 55440
2021-02-06T21:15:26.326261+00:00 app[web.1]: (node:38) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2021-02-06T21:15:26.737056+00:00 heroku[web.1]: State changed from starting to up
2021-02-06T21:15:28.970599+00:00 app[web.1]: (node:38) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: callback is not a function
2021-02-06T21:15:37.216680+00:00 heroku[router]: at=info method=GET path="/" host=herokumongodbsmackchat.herokuapp.com request_id=07df9b72-f6d2-4c33-b0f0-8635c162a76e fwd="103.777.777.777" dyno=web.1 connect=0ms service=18ms status=304 bytes=150 protocol=https
2021-02-06T21:15:58.686858+00:00 heroku[router]: at=info method=GET path="/v1/user" host=herokumongodbsmackchat.herokuapp.com request_id=568ce1a9-691f-4fdf-b91a-fd17b833dcfb fwd="103.777.777.777" dyno=web.1 connect=1ms service=8ms status=404 bytes=390 protocol=https
tromgy commented 3 years ago

Here's your problem:

2021-02-06T21:15:28.970599+00:00 app[web.1]: (node:38) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: callback is not a function

So interestingly, it doesn't crash the whole process, but prevents the code that builds the routes from executing.

You probably should try to debug it on a local server. Since there's neither mongo url nor "Database connection ready" messages, it seems likely that this exception is thrown from somewhere inside the mongoose.connect call, and this "callback" it is referring to is not the callback argument passed to the exported function in db.js

SumukhaK commented 3 years ago

Okay. while I understand what you are trying to say, I'm a no show when it comes to js. Here I'm attaching my code , if you can look into it and let me know the fix it will be a great deal of help. I can't spend a lot of time on fixing a js code issue while I'm actually trying to learn Kotlin and move ahead in that direction. Thanks a lot, my man.

https://github.com/SumukhaK/LearnKotlin-macChatModified

tromgy commented 3 years ago

I found a problem in your code:

mongoose.connect(config.mongoUrl, { useNewUrlParser: true },{ useMongoClient: true },{ useUnifiedTopology: true },function (err, database)...

mongoose.connect takes 3 arguments:

but you are passing 5, so it thinks that { useMongoClient: true} is the callback function! And that was the source of that "TypeError: callback is not a function" error.

You should pass all options as one object, not three:

mongoose.connect(config.mongoUrl, { useNewUrlParser: true, useMongoClient: true, useUnifiedTopology: true }, function (err, database)...

Now, the useMongoClient option is unnecessary, and mongoose will complain:

WARNING: The `useMongoClient` option is no longer necessary in mongoose 5.x, please remove it.

Secondly, a word of caution -- ‼️NEVER ‼️commit to github any private information, such as the password in the mongodb connection string in your case.

And finally, there's still a problem with your password/database name --

Why do you have < > and ' ' around your password and < > around your database name?

Your connection string (in config/db.js) should be (pasting it here with the full password, as it is already in the open):

mongoUrl:
    'mongodb+srv://testUser:HTh5MyH3A10RSznM@mongodbtest.yxsef.mongodb.net/database?retryWrites=true&w=majority', //"mongodb+srv://testUser:<FWEMXfr2eh4wdgBA>@mongodbtest.yxsef.mongodb.net/<test-db>?retryWrites=true&w=majority"

and probably your database shouldn't be named "database", but something more specific to the application.

Don't forget to change you mongodb password after you got it all straightened out!

SumukhaK commented 3 years ago

Wow ! it worked like a charm. You have no idea how helpful you were to me ! I don't even know your name but you have made a significant impact on my learning curve today. Thanks a million. I never wanted to share usernames and password but I did that anyway out of desperation for help. Because the app I 'm going to build using this API was almost a real app with actually working, useful functionalities which would make an instant impact on my coding confidence. I have already changed my password, API is up and running and I made a couple of successful POST queries. So, shout out for a coding ninja who helped my Kotlin course. May you have a hugely successful career and a peaceful life :)

Forgot to mention : Once I pushed my code to Git with password I received a mail by GitGuardian saying: GitGuardian has detected the following MongoDB URI exposed within your GitHub account.

So when I enabled few options from that mail, I thought it straighten out my mistake.

tromgy commented 3 years ago

Well, good luck with your Kotlin endeavors!