Instagram Webhook Error, cannot load profile for <igsid> - instagram

I'm trying to get instagram messages with webhooks. I cloned the example "OC Coast Clothing IG" in github and upload on heroku.
However, when I test the webhook "messages" I get an error and my server crashes.
Here is my logs:
Could not load profile for 12334(this is the test id): Bad RequestTypeError: Cannot read properties of undefined (reading 'name')
2022-12-15T17:43:32.077647+00:00 app[web.1]: at Receive.handleTextMessage (/app/services/receive.js:78:45)
2022-12-15T17:43:32.077647+00:00 app[web.1]: at Receive.handleMessage (/app/services/receive.js:45:28)
2022-12-15T17:43:32.077649+00:00 app[web.1]: at /app/app.js:141:31
2022-12-15T17:43:32.077650+00:00 app[web.1]: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2022-12-15T17:43:32.078205+00:00 app[web.1]: /app/services/receive.js:238
2022-12-15T17:43:32.078206+00:00 app[web.1]: id: this.user.igsid
2022-12-15T17:43:32.078206+00:00 app[web.1]: ^
2022-12-15T17:43:32.078207+00:00 app[web.1]:
2022-12-15T17:43:32.078207+00:00 app[web.1]: TypeError: Cannot read properties of undefined (reading 'igsid')
2022-12-15T17:43:32.078208+00:00 app[web.1]: at Receive.sendMessage (/app/services/receive.js:238:23)
2022-12-15T17:43:32.078208+00:00 app[web.1]: at Receive.handleMessage (/app/services/receive.js:71:12)
2022-12-15T17:43:32.078209+00:00 app[web.1]: at /app/app.js:141:31
2022-12-15T17:43:32.078209+00:00 app[web.1]: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2022-12-15T17:43:32.078209+00:00 app[web.1]:
I have all the needed permissions, I can see the received webhook and the JSON data. I didn't change the example github code. Do I need to install some libraries in heroku terminal or what?

Related

throw new Error('Cannot create a client without an access token');

I have almost deployed my app with heroku and when I try to add a campground in this case, it just gives me a blank thing. No error. This is what I get in my logs:
[[2021-10-15T20:53:49.474030+00:00 app[web.1]: (cloudinary secret)
2021-10-15T20:53:49.474721+00:00 app[web.1]: undefined
2021-10-15T20:53:50.059515+00:00 app[web.1]: /app/node_modules/#mapbox/mapbox-sdk/lib/classes/mapi-client.js:25
2021-10-15T20:53:50.059537+00:00 app[web.1]: throw new Error('Cannot create a client without an access token');
2021-10-15T20:53:50.059538+00:00 app[web.1]: ^
2021-10-15T20:53:50.059538+00:00 app[web.1]:
2021-10-15T20:53:50.059539+00:00 app[web.1]: Error: Cannot create a client without an access token]]
I have added all of my env variables. Checked them 3 times.

Selenium on heroku DevToolsActivePort file doesn't exist

So, I'm trying to deploy a node, selenium app to heroku.
This is how my code looks
let options = new Options();
options.setChromeBinaryPath(process.env.GOOGLE_CHROME_BIN);
options.addArguments("--headless");
options.addArguments("--start-maximized");
options.addArguments("--headless");
options.addArguments("--disable-dev-usage");
options.addArguments("--window-size=1920,1080");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--allow-running-insecure-content");
options.setUserPreferences({"prefs":{"useAutomationExtension": false}});
let serviceBuilder = new ServiceBuilder();
console.log("initialized serice builder");
let driver = new Builder(process.env.CHROME_EXECUTABLE_PATH)
.forBrowser(Browser.CHROME)
.setChromeOptions(options)
.setChromeService(serviceBuilder)
.build();
This throws an error on the heroku logs like so
2021-05-18T05:42:15.372134+00:00 app[web.1]: /app/node_modules/selenium-webdriver/lib/error.js:517
2021-05-18T05:42:15.372174+00:00 app[web.1]: let err = new ctor(data.message)
2021-05-18T05:42:15.372175+00:00 app[web.1]: ^
2021-05-18T05:42:15.372176+00:00 app[web.1]:
2021-05-18T05:42:15.372176+00:00 app[web.1]: WebDriverError: unknown error: Chrome failed to start: crashed.
2021-05-18T05:42:15.372177+00:00 app[web.1]: (unknown error: DevToolsActivePort file doesn't exist)
2021-05-18T05:42:15.372180+00:00 app[web.1]: (The process started from chrome location /app/.apt/opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
2021-05-18T05:42:15.372181+00:00 app[web.1]: at Object.throwDecodedError (/app/node_modules/selenium-webdriver/lib/error.js:517:15)
2021-05-18T05:42:15.372181+00:00 app[web.1]: at parseHttpResponse (/app/node_modules/selenium-webdriver/lib/http.js:642:13)
2021-05-18T05:42:15.372181+00:00 app[web.1]: at Executor.execute (/app/node_modules/selenium-webdriver/lib/http.js:568:28)
2021-05-18T05:42:15.372182+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2021-05-18T05:42:15.372182+00:00 app[web.1]: remoteStacktrace: '#0 0x5630d5f6be89 <unknown>\n'
2021-05-18T05:42:15.372183+00:00 app[web.1]: }
2021-05-18T05:42:15.465529+00:00 heroku[web.1]: Process exited with status 1
2021-05-18T05:42:15.532468+00:00 heroku[web.1]: State changed from up to crashed
Nothing seems to fix the issue, I've added the required buildpacks, and have also checked all the versions. Also note that this code runs perfectly fine on my local machine. I saw a similar question where the user manually added the DevToolsActivePort file, but that doesn't seem to be possible as I can't ssh into the heroku server.
Thanks in advance.
You will need to pass in a flag to disable Chrome Devtools Sandbox, so it will no longer look for DevToolsActivePort. It is also recommended to disable-gpu with a headless webdriver:
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-gpu");

TypeError: str.charAt is not a function at parse (/app/node_modules/pg-connection-string/index.js:13:11)

I have a node and express api deployed on Heroku and the api works fine for normal GET requests but when I try to Get or Post a request that involves querying a Postgre database from heroku add ons, such as registering a new user , it gives me error with this error log:
2020-09-13T18:48:39.984122+00:00 app[web.1]: TypeError: str.charAt is not a function
2020-09-13T18:48:39.984146+00:00 app[web.1]: at parse (/app/node_modules/pg-connection-string/index.js:13:11)
2020-09-13T18:48:39.984147+00:00 app[web.1]: at new ConnectionParameters (/app/node_modules/pg/lib/connection-parameters.js:56:42)
2020-09-13T18:48:39.984148+00:00 app[web.1]: at new Client (/app/node_modules/pg/lib/client.js:19:33)
2020-09-13T18:48:39.984148+00:00 app[web.1]: at BoundPool.newClient (/app/node_modules/pg-pool/index.js:201:20)
2020-09-13T18:48:39.984149+00:00 app[web.1]: at BoundPool.connect (/app/node_modules/pg-pool/index.js:195:10)
2020-09-13T18:48:39.984150+00:00 app[web.1]: at BoundPool.query (/app/node_modules/pg-pool/index.js:343:10)
2020-09-13T18:48:39.984150+00:00 app[web.1]: at /app/routes/UserAuth/jwtAuth.js:19:33
2020-09-13T18:48:39.984150+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-09-13T18:48:39.984151+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2020-09-13T18:48:39.984151+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
Two possibilities due to which you might be getting this error :
1.You are trying to access some other datatype as a string.
2.You are passing this as a callback, but str.charAt() returns a character and not function.
Check for both scenarios and since you have not shared code snippet, so could not suggest the exact code implemented solution.

METEOR_SETTINGS is not valid json error when deploying meteor app to heroku

As the title says, I am getting that error when deploying my meteor app to heroku. I have already validated my settings.json file with JSONlint and have searched for any possible fix but I have not come across any which work. My error logs are as shown below. Could anyone tell me what might be wrong?
2017-09-03T11:18:31.226632+00:00 heroku[web.1]: Starting process with command `.meteor/heroku_build/bin/node $NODEJS_PARAMS .meteor/heroku_build/app/main.js`
2017-09-03T11:18:33.344368+00:00 app[web.1]: /app/.meteor/heroku_build/app/programs/server/boot.js:391
2017-09-03T11:18:33.344382+00:00 app[web.1]: }).run();
2017-09-03T11:18:33.344383+00:00 app[web.1]: ^
2017-09-03T11:18:33.344384+00:00 app[web.1]:
2017-09-03T11:18:33.344385+00:00 app[web.1]: Error: METEOR_SETTINGS are not valid JSON: $(cat settings.json)
2017-09-03T11:18:33.344385+00:00 app[web.1]: at packages/meteor.js:59:11
2017-09-03T11:18:33.344386+00:00 app[web.1]: at packages/meteor.js:80:4
2017-09-03T11:18:33.344387+00:00 app[web.1]: at packages/meteor.js:1380:3
2017-09-03T11:18:33.344388+00:00 app[web.1]: at /app/.meteor/heroku_build/app/programs/server/boot.js:338:34
2017-09-03T11:18:33.344388+00:00 app[web.1]: at Array.forEach (native)
2017-09-03T11:18:33.344389+00:00 app[web.1]: at Function._.each._.forEach (/app/.meteor/heroku_build/app/programs/server/node_modules/underscore/underscore.js:79:11)
2017-09-03T11:18:33.344390+00:00 app[web.1]: at /app/.meteor/heroku_build/app/programs/server/boot.js:158:5
2017-09-03T11:18:33.344391+00:00 app[web.1]: at /app/.meteor/heroku_build/app/programs/server/boot.js:387:5
2017-09-03T11:18:33.344392+00:00 app[web.1]: at Function.run (/app/.meteor/heroku_build/app/programs/server/profile.js:510:12)
2017-09-03T11:18:33.344392+00:00 app[web.1]: at /app/.meteor/heroku_build/app/programs/server/boot.js:386:11
2017-09-03T11:18:33.415049+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-03T11:18:33.400865+00:00 heroku[web.1]: Process exited with status 1
Your problem is with this command:
heroku config:add METEOR_SETTINGS="$(cat settings.json)"
You see, on Windows, the $(cat settings.json) means just text, but on Mac/*nix that means "get content of settings.json file".
I'd recommend to use git bash cli to run this command there. Link to Git for Windows (with git bash cli): https://git-for-windows.github.io/
In windows, you can compress the setting.json file in notepad++ (Plugins->JSON viewer -> Compress JSON) then run the below command by coping the compressed json content as follow
SET METEOR_SETTINGS={"configuration":{"images-folder":"","internal-folder":"","demo-mode":false},"sets-of-classes":[{"name":"Cityscapes","objects":[{"label":"VOID","color":"#CFCFCF"},{"label":"Road","color":"#804080","icon":"Road"},{"label":"Sidewalk","........
now you can run the usual command

Error: failed to connect to [localhost:27017] when running MEAN app on HEROKU

I'm writing my second MEAN app. The first one was build aggregating the components by hand (I was not aware of MEAN) and hosting it at HEROKU; I attempted to use MONGOOSE but gave up due to problems connecting with the database at HEROKU - it worked fine on my MAC. This time around it works on my MAC but I'm still having connection problems; I do not want to jettison MONGOOSE. At this point all I have is the vanilla MEAN app built off its zip file, the zip file downloaded from the MEAN GitHUB repository. See below for the logs I get from HEROKU:
2013-09-10T01:33:28.045816+00:00 heroku[web.1]: Starting process with command `grunt`
2013-09-10T01:33:29.526090+00:00 app[web.1]: Running "jshint:all" (jshint) task
2013-09-10T01:33:29.567534+00:00 app[web.1]: >> 1 file lint free.
2013-09-10T01:33:29.568809+00:00 app[web.1]:
2013-09-10T01:33:29.568809+00:00 app[web.1]: Running "compass:dist" (compass) task
2013-09-10T01:33:29.573055+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574527+00:00 app[web.1]: Warning: Cannot read property 'stdout' of undefined Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]:
2013-09-10T01:33:29.575774+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]: Running "compass:dev" (compass) task
2013-09-10T01:33:29.576128+00:00 app[web.1]: Running "concurrent:target" (concurrent) task
2013-09-10T01:33:29.576043+00:00 app[web.1]:
2013-09-10T01:33:30.414023+00:00 app[web.1]: Running "nodemon:dev" (nodemon) task
2013-09-10T01:33:30.511082+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] v0.7.10
2013-09-10T01:33:30.511537+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] to restart at any time, enter `rs`
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/config
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/app
2013-09-10T01:33:30.536018+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] Unable to write to temp directory. If you experience problems with file reloading, ensure /tmp is writable.
2013-09-10T01:33:30.550590+00:00 app[web.1]: debugger listening on port 5858
2013-09-10T01:33:30.578354+00:00 app[web.1]: Running "watch" task
2013-09-10T01:33:30.624330+00:00 app[web.1]: Waiting...10 Sep 01:33:30 - [nodemon] reading ignore list
2013-09-10T01:33:31.152639+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-09-10T01:33:31.154862+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-09-10T01:33:31.148967+00:00 app[web.1]: Express app started on port 3000
2013-09-10T01:33:31.152143+00:00 app[web.1]:
2013-09-10T01:33:31.152401+00:00 app[web.1]: events.js:72
2013-09-10T01:33:31.154862+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-09-10T01:33:31.154862+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
Any comments of suggestions would be much welcome. Thanks in advance.
You need to host MongoDB somewhere. There are a number of MongoDB hosting services, MongoHQ and MongoLab the most popular. I have used MongoHQ with good results although I must admit I haven't stressed my system. You can sign up for the free trial (I think you get 512MB), once you have done that, replace your connection string with (you will get all the details when signing up):
'mongodb://username:password#domain:port/dbName'

Resources