Below is the output when running app.js. This started occurring totally at random when everything was working fine. Absolutely no changes were made.
TypeError: Cannot read property 'message' of undefined
at /home/ec2-user/environment/rt-bot/app.js:78:48
at Request._callback (/home/ec2-user/environment/node_modules/twitter/lib/twitter.js:220:14)
at Request.self.callback (/home/ec2-user/environment/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/home/ec2-user/environment/node_modules/request/request.js:1163:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IningMessage.<anonymous> (/home/ec2-user/environment/node_modules/request/request.js:1085:12)
at IningMessage.g (events.js:292:16)
I've tried creating new instances from my master branch (with no mits since last working) and even still getting this error. Any ideas?
The code causing the error, though this code was working previously.
T.get('search/tweets', query, function(err, data, response) {
// continue if no errors
if(!err){
// loop
for(let i = 0; i < data.statuses.length; i++){
// get latest tweet ID
let id = { id: data.statuses[i].id_str }
// try favorite
T.post('favorites/create', id, function(err, response){
// log failures
if(err){
console.log('Try Favorite - ', err[0].message);
}
// log success
else{
let username = response.user.screen_name;
let tweetId = response.id_str;
console.log('Favorited: ', `/${username}/status/${tweetId}`)
}
});
Image of first occurrence. As you can see everything was functioning fine, then this error came out of nowhere with absolutely no changes to environment or codebase.
UPDATE:
Output when logging error with console.log('Try Favorite - ', err.message);
rather than console.log('Try Favorite - ', err[0].message);
[[Apr 28 21:27:00.702]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.705]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.706]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.707]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.708]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.709]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.712]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.713]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.718]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.793]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
Also note that the retweet function uses the same console logging method. See code below, and outputs fine.
// try retweet
T.post('statuses/retweet', id, function(err, response){
// log failures
if(err){
console.log('Try Retweet - ', err[0].message);
}
Below is the output when running app.js. This started occurring totally at random when everything was working fine. Absolutely no changes were made.
TypeError: Cannot read property 'message' of undefined
at /home/ec2-user/environment/rt-bot/app.js:78:48
at Request._callback (/home/ec2-user/environment/node_modules/twitter/lib/twitter.js:220:14)
at Request.self.callback (/home/ec2-user/environment/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/home/ec2-user/environment/node_modules/request/request.js:1163:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IningMessage.<anonymous> (/home/ec2-user/environment/node_modules/request/request.js:1085:12)
at IningMessage.g (events.js:292:16)
I've tried creating new instances from my master branch (with no mits since last working) and even still getting this error. Any ideas?
The code causing the error, though this code was working previously.
T.get('search/tweets', query, function(err, data, response) {
// continue if no errors
if(!err){
// loop
for(let i = 0; i < data.statuses.length; i++){
// get latest tweet ID
let id = { id: data.statuses[i].id_str }
// try favorite
T.post('favorites/create', id, function(err, response){
// log failures
if(err){
console.log('Try Favorite - ', err[0].message);
}
// log success
else{
let username = response.user.screen_name;
let tweetId = response.id_str;
console.log('Favorited: ', `https://twitter./${username}/status/${tweetId}`)
}
});
Image of first occurrence. As you can see everything was functioning fine, then this error came out of nowhere with absolutely no changes to environment or codebase.
UPDATE:
Output when logging error with console.log('Try Favorite - ', err.message);
rather than console.log('Try Favorite - ', err[0].message);
[[Apr 28 21:27:00.702]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.705]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.706]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.707]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.708]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.709]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.712]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.713]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.718]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
[[Apr 28 21:27:00.793]] [LOG] Try Favorite - HTTP Error: 429 Too Many Requests
Also note that the retweet function uses the same console logging method. See code below, and outputs fine.
// try retweet
T.post('statuses/retweet', id, function(err, response){
// log failures
if(err){
console.log('Try Retweet - ', err[0].message);
}
Share
Improve this question
edited Apr 28, 2018 at 21:30
CodeSpent
asked Apr 28, 2018 at 21:09
CodeSpentCodeSpent
1,9245 gold badges27 silver badges50 bronze badges
4
- 1 Try logging err without [0] – Tiago Coelho Commented Apr 28, 2018 at 21:25
- I'm checking rate limits currently to see if they've possibly been rate limited on favorites for the day, though typically it outputs differently, it would explain the randomness of the occurrence. – CodeSpent Commented Apr 28, 2018 at 21:34
- GET favorites/list rate limit is 75 per window (15 minutes), whereas GET search/tweets is 180(user) - 450(app) per window. Running numbers for all requests quick. – CodeSpent Commented Apr 28, 2018 at 21:37
- So if I'm understanding correctly, the reason I'm getting the error is because its requesting the Code 429 message rather than the "You have already favorited this Tweet" message which are likely delivered differently? Running the numbers, though, it doesn't seem the user should be being rate limited, and the rate limit should release at the start of a new window, yet this has been occurring for much longer. – CodeSpent Commented Apr 28, 2018 at 21:40
1 Answer
Reset to default 1Twit uses request to send HTTP requests to Twitter API, so the error will be single object not an array, so your error handler will look like
if(err){
console.log('Try Favorite - ', err.message);
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745245328a4618384.html
评论列表(0条)