meanjs 0.4.0 not working when deployed to Heroku - heroku

I've just tried the meanjs 0.4.0 in local host and runs fine but when I deploy to heroku link to app and try the "Sign up" option I get this in the navegator console:
POST https://meanjsapptest.herokuapp.com/api/auth/signup 503 (Service Unavailable)
and when I write the comand heroku logs in the CLI I get:
2017-06-06T04:15:35.152983+00:00 app[web.1]: (node:16) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
2017-06-06T04:15:35.153005+00:00 app[web.1]: crypto.js:635
2017-06-06T04:15:35.153006+00:00 app[web.1]: throw new TypeError(
2017-06-06T04:15:35.153006+00:00 app[web.1]: ^
2017-06-06T04:15:35.153007+00:00 app[web.1]:
2017-06-06T04:15:35.153008+00:00 app[web.1]: TypeError: The "digest" argument is required and must not be undefined
2017-06-06T04:15:35.153009+00:00 app[web.1]: at pbkdf2 (crypto.js:635:11)
2017-06-06T04:15:35.153010+00:00 app[web.1]: at Object.exports.pbkdf2Sync (crypto.js:628:10)
2017-06-06T04:15:35.153012+00:00 app[web.1]: at model. (/app/modules/users/server/models/user.server.model.js:112:26)
2017-06-06T04:15:35.153011+00:00 app[web.1]: at model.UserSchema.methods.hashPassword (/app/modules/users/server/models/user.server.model.js:123:19)
2017-06-06T04:15:35.153013+00:00 app[web.1]: at _next (/app/node_modules/hooks-fixed/hooks.js:62:30)
2017-06-06T04:15:35.153013+00:00 app[web.1]: at fnWrapper (/app/node_modules/hooks-fixed/hooks.js:186:8)
2017-06-06T04:15:35.153014+00:00 app[web.1]: at model. (/app/node_modules/mongoose/lib/plugins/saveSubdocs.js:20:7)
2017-06-06T04:15:35.153014+00:00 app[web.1]: at _next (/app/node_modules/hooks-fixed/hooks.js:62:30)
2017-06-06T04:15:35.153015+00:00 app[web.1]: at fnWrapper (/app/node_modules/hooks-fixed/hooks.js:186:8)
2017-06-06T04:15:35.153015+00:00 app[web.1]: at /app/node_modules/mongoose/lib/plugins/validateBeforeSave.js:33:13
2017-06-06T04:15:35.153016+00:00 app[web.1]: at /app/node_modules/kareem/index.js:131:16
2017-06-06T04:15:35.153016+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:95:7)
2017-06-06T04:15:35.153017+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:161:9)
2017-06-06T04:15:35.167579+00:00 app[web.1]: error: Forever detected script exited with code: 1
2017-06-06T04:15:35.173500+00:00 app[web.1]: error: Script restart attempt #1
2017-06-06T04:15:35.292903+00:00 app[web.1]:
2017-06-06T04:15:35.294191+00:00 app[web.1]:
2017-06-06T04:15:35.310954+00:00 app[web.1]: + Error: Certificate file or key file is missing, falling back to non-SSL mode
2017-06-06T04:15:35.311037+00:00 app[web.1]: To create them, simply run the following from your shell: sh ./scripts/generate-ssl-certs.sh
2017-06-06T04:15:35.311039+00:00 app[web.1]:
2017-06-06T04:15:35.916892+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
I don't know what to do now because Heroku supports tell me thar the error is in my code but I haven't changed anything there!
CLI screenshot

Just had this problem. We were able to fix it by enforcing our preferred node version in package.json > engines.
We previously had it at
"node": ">=0.10.0"
We changed it to
"node": "6.6.0"
And then pushed that to Heroku, and that fixed the issue.
Not entirely sure what the problem is, but we found this link which lead us to believe the node version was the issue:
https://github.com/nodejs/node/wiki/Breaking-changes-between-v4-LTS-and-v6-LTS#crypto

Related

NestJS (Nx workspace) build failing on Heroku

I'm trying to deploy a NestJS app (in Nx workspace) on Heroku, but the deploy is failing with error:
2021-12-24T11:03:17.280952+00:00 app[web.1]: at /app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:26:38
2021-12-24T11:03:17.280953+00:00 app[web.1]: at Array.forEach (<anonymous>)
2021-12-24T11:03:17.280953+00:00 app[web.1]: at Function.createForClass (/app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:25:86)
2021-12-24T11:03:17.280954+00:00 app[web.1]: at Function.createForClass (/app/node_modules/#nestjs/mongoose/dist/factories/schema.factory.js:9:75)
2021-12-24T11:03:17.280954+00:00 app[web.1]: at Object.89 (/app/dist/apps/api/main.js:1:4717)
2021-12-24T11:03:17.280954+00:00 app[web.1]: at o (/app/dist/apps/api/main.js:1:12427)
2021-12-24T11:03:17.280955+00:00 app[web.1]: at Object.812 (/app/dist/apps/api/main.js:1:5865)
2021-12-24T11:03:17.280955+00:00 app[web.1]: at o (/app/dist/apps/api/main.js:1:12427)
2021-12-24T11:03:17.424198+00:00 heroku[web.1]: Process exited with status 1
2021-12-24T11:03:17.602083+00:00 heroku[web.1]: State changed from starting to crashed
I have seen some Mongoose issues and they don't seem to be the problem here, since the packages have since gotten multiple updates.
Edit:
After running the app from the Heroku console I got a more explicit error:
/app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:43
optionsOrType = isClass ? optionsOrType : optionsOrType();
^
TypeError: Class constructors cannot be invoked without 'new'
at Function.inspectTypeDefinition (/app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:43:55)
at Function.inspectTypeDefinition (/app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:52:39)
at /app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:26:38
at Array.forEach (<anonymous>)
at Function.createForClass (/app/node_modules/#nestjs/mongoose/dist/factories/definitions.factory.js:25:86)
at Function.createForClass (/app/node_modules/#nestjs/mongoose/dist/factories/schema.factory.js:9:75)
at Object.89 (/app/dist/apps/api/main.js:1:4301)
at o (/app/dist/apps/api/main.js:1:12011)
at Object.812 (/app/dist/apps/api/main.js:1:5449)
at o (/app/dist/apps/api/main.js:1:12011)
I had the same problem and it was caused by an upgrade of nrwl/nx to 13.3.1.
A downgrade of nrwl/nx to 13.2.4 fixed it.
So it seems that nx 13.3.0 introduced a dependency update which breaks the application.

NameError - unitilaized constant - only in production

I have a ruby on rails app that is hosted on heroku. When I try to create an item running it in "development" mode, everything works great and there are no issues. However, when I switch the app to run in "production" mode I'm getting the following.
This was a Ruby 2.2.x upgraded to 2.5.x and rails 4.1 upgraded to 5.2.
Any ideas or suggestions on why this is failing in production but works fine in development?
Started POST "/items" for 1.2.3.4 at 2020-10-19 03:22:06 +0000
2020-10-19T03:22:06.870055+00:00 app[web.1]: Processing by ItemController#create as HTML
2020-10-19T03:22:06.870358+00:00 app[web.1]: Parameters: {###Redacted##}
2020-10-19T03:22:06.926046+00:00 app[web.1]: Completed 500 Internal Server Error in 54ms (ActiveRecord: 15.8ms)
2020-10-19T03:22:06.999133+00:00 app[web.1]: I, [2020-10-19T03:22:06.998984 #11] INFO -- : Sending event 18b887c876d4524b5cd46849a98aaeb1 to Sentry
2020-10-19T03:22:07.271068+00:00 app[web.1]:
2020-10-19T03:22:07.271478+00:00 app[web.1]: NameError (uninitialized constant #<Class:0x0000567238d68165>::Slug):
2020-10-19T03:22:07.276183+00:00 app[web.1]:
2020-10-19T03:22:07.276248+00:00 app[web.1]: app/models/item.rb:305:in `name_to_slug'
2020-10-19T03:22:07.276248+00:00 app[web.1]: app/models/item.rb:293:in `generate_slug'
I tracked this back to a custom class that was located in the "lib" folder. Moving from Rails 4 to 5 it seems like some behaviors changed with loading custom classes which needed to be accounted for:
https://gist.github.com/maxivak/381f1e964923f1d469c8d39da8e2522f

Why is the bot on Heroku Server not responding?

I programmed a simple bot that is connected to Google Sheets API. It asks a few questions to the user and stores it in the Sheet I have. When I use bot.polling it works fine, but I was trying the webhook so I could use Heroku to have my bot running 24/7.
I introduced the code:
#server.route('/' + token, methods=['POST'])
def getMessage():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
return "!", 200
#server.route("/")
def webhook():
bot.remove_webhook()
bot.set_webhook(url = '<Heroku App Link>' + token)
return "!", 200
if __name__ == "__main__":
server.run(host="0.0.0.0", port = int(os.environ.get('PORT', 5000)))
I have the requirements.txt file and the Procfile that currently is like this:
web: python3 bot.py
I tried a bunch of things in the Procfile but this is the only one that didn't gave an error.
When I saw the log this is what I got:
2019-09-24T10:18:54.369238+00:00 heroku[web.1]: State changed from crashed to starting
2019-09-24T10:19:04.416777+00:00 heroku[web.1]: Starting process with command `python3 bot.py`
2019-09-24T10:19:09.868915+00:00 heroku[web.1]: State changed from starting to up
2019-09-24T10:19:09.790773+00:00 app[web.1]: * Serving Flask app "bot" (lazy loading)
2019-09-24T10:19:09.790800+00:00 app[web.1]: * Environment: production
2019-09-24T10:19:09.790853+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2019-09-24T10:19:09.790940+00:00 app[web.1]: Use a production WSGI server instead.
2019-09-24T10:19:09.790991+00:00 app[web.1]: * Debug mode: off
2019-09-24T10:19:09.799470+00:00 app[web.1]: * Running on http://0.0.0.0:57826/ (Press CTRL+C to quit)
2019-09-24T10:19:15.000000+00:00 app[api]: Build succeeded
Can anyone help me understand why the bot doesn't answer any commands?

Setting up Sentry in an Elixir app, getting undefined function String.trim/2

I'm following these instructions (https://github.com/getsentry/sentry-elixir) to set up Sentry error notifications in an Elixir/Phoenix app. It works fine in my dev environment, but when I push to production (using Heroku) I get the following error which seems to occur within the Sentry module itself: (UndefinedFunctionError) undefined function String.trim/2.
Here is the full log output:
** (exit) an exception was raised:
2016-12-01T23:14:00.741733+00:00 app[web.1]: ** (UndefinedFunctionError) undefined function String.trim/2
2016-12-01T23:14:00.741736+00:00 app[web.1]: (elixir) String.trim("** (Phoenix.ActionClauseError) bad request to MyApp.UserController.create, no matching action clause to process request", "*")
2016-12-01T23:14:00.741737+00:00 app[web.1]: (sentry) lib/sentry/event.ex:65: Sentry.Event.transform_exception/2
2016-12-01T23:14:00.741738+00:00 app[web.1]: (sentry) lib/sentry.ex:86: Sentry.capture_exception/2
2016-12-01T23:14:00.741739+00:00 app[web.1]: (plug) lib/plug/error_handler.ex:96: Plug.ErrorHandler.__catch__/5
2016-12-01T23:14:00.741740+00:00 app[web.1]: (my_app) lib/my_app/endpoint.ex:1: MyApp.Endpoint.phoenix_pipeline/1
2016-12-01T23:14:00.741741+00:00 app[web.1]: (my_app) lib/my_app/endpoint.ex:1: MyApp.Endpoint.call/2
2016-12-01T23:14:00.741742+00:00 app[web.1]: (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
2016-12-01T23:14:00.741742+00:00 app[web.1]: (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
and when I try to access alias String by logging into the iex via heroku run, I get nil.
Any idea why the String module is undefined in production only?
i think you need to force heroku to use elixir version 1.3.x
If you use the heroku-buildpack-elixir set your elixir version to minimum of 1.3.0
https://github.com/HashNuke/heroku-buildpack-elixir
There is the corresponding issue:
https://github.com/getsentry/sentry-elixir/issues/95

Push rejected failed to detect set buildpack heroku/ruby

I'm attempting to add the following project to my slack chat "https://github.com/PDaily/lita-destiny" I have added the lita integration on my slack chat. I've made a new app on the heroku site, I've added to the global config vars, my LITA_TOKEN, GITHUB_URL and by BUNGIE_API_KEY. I've used cmd and the heroku toolkit and logged in to heroku. I've then changed directory to where the lita-destiny folder is located. I've then done
Bundle install
Git add.
Git add -u
Git commit -m "heroku"
Git push heroku master.
I've installed all the native gems, also in the root of that folder is a gemfile.
However I get the error in the title there. I've also performed
heroku buildpacks:set heroku/ruby
2016-03-31T00:14:25+00:00 app[heroku-redis]: source=REDIS sample#active-connections=1 sample#load-avg-1m=0.33 sample#load-avg-5m=0.24 sample#load-avg-15m=0.215 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15405632.0kB sample#memory-free=13328628.0kB sample#memory-cached=482376kB sample#memory-redis=294048bytes sample#hit-rate=1 sample#evicted-keys=0
2016-03-31T00:15:24+00:00 app[heroku-redis]: source=REDIS sample#active-connections=1 sample#load-avg-1m=0.255 sample#load-avg-5m=0.235 sample#load-avg-15m=0.215 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15405632.0kB sample#memory-free=13328504.0kB sample#memory-cached=482372kB sample#memory-redis=294048bytes sample#hit-rate=1 sample#evicted-keys=0
2016-03-31T00:16:48.562723+00:00 heroku[api]: Release v12 created by munkeyboy14#gmail.com
2016-03-31T00:16:48.562723+00:00 heroku[api]: Deploy 97376bc by munkeyboy14#gmail.com
2016-03-31T00:16:48.723963+00:00 heroku[slug-compiler]: Slug compilation started
2016-03-31T00:16:48.723974+00:00 heroku[slug-compiler]: Slug compilation finished
2016-03-31T00:16:48.698905+00:00 heroku[web.1]: State changed from crashed to starting
2016-03-31T00:16:48+00:00 app[heroku-redis]: source=REDIS sample#active-connections=1 sample#load-avg-1m=0.22 sample#load-avg-5m=0.24 sample#load-avg-15m=0.22 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15405632.0kB sample#memory-free=13328232.0kB sample#memory-cached=482380kB sample#memory-redis=294048bytes sample#hit-rate=1 sample#evicted-keys=0
2016-03-31T00:16:50.125875+00:00 heroku[web.1]: Starting process with command `bundle exec lita`
2016-03-31T00:16:52.409755+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/lita-slack-1.7.2/lib/lita/adapters/slack/api.rb:63:in `call_api': Slack API call to rtm.start returned an error: invalid_auth. (RuntimeError)
2016-03-31T00:16:52.409772+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-slack-1.7.2/lib/lita/adapters/slack/api.rb:38:in `rtm_start'
2016-03-31T00:16:52.409773+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-slack-1.7.2/lib/lita/adapters/slack/rtm_connection.rb:20:in `build'
2016-03-31T00:16:52.409774+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-slack-1.7.2/lib/lita/adapters/slack.rb:22:in `run'
2016-03-31T00:16:52.409774+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-4.7.0/lib/lita/robot.rb:80:in `run'
2016-03-31T00:16:52.409775+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-4.7.0/lib/lita.rb:80:in `run'
2016-03-31T00:16:52.409776+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-4.7.0/lib/lita/cli.rb:77:in `start'
2016-03-31T00:16:52.409778+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
2016-03-31T00:16:52.409778+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
2016-03-31T00:16:52.409779+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
2016-03-31T00:16:52.409780+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
2016-03-31T00:16:52.409800+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/bin/lita:23:in `load'
2016-03-31T00:16:52.409782+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/lita-4.7.0/bin/lita:6:in `<top (required)>'
2016-03-31T00:16:52.409800+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/bin/lita:23:in `<main>'
2016-03-31T00:16:53.126028+00:00 heroku[web.1]: Process exited with status 1
2016-03-31T00:16:53.137278+00:00 heroku[web.1]: State changed from starting to crashed
above is the latest error message from heroku logs
If I am understanding your question correctly, there is a fundamental misunderstanding about how lita works. The lita gem has an executable (lita new) that creates a new lita bot for you. You then add plugins like lita-destiny to the Gemfile of your lita bot.
So you are getting this error because you are not pushing code that Heroku recognizes as a Ruby app-- you are pushing a gem.
What you should do is
cd ../some/place/else
gem install lita
lita new
cd lita
echo 'web: bundle exec lita' >> Procfile
bundle install
git init
git add .
git commit -m 'Initial commit'
heroku apps:create
git push heroku master
Then you can add the lita-destiny plugin to the Gemfile of your lita bot (the project you just created above) and add config.handlers.destiny_handler.api_key = 'XXXX' to the lita_config.rb file in that same project. You also add your Slack API Key to the lita_config.rb file.
Source: lita docs and heroku docs

Resources