以下是运行app.js时的输出。当一切正常时,这开始完全随机发生。绝对没有做出任何改变。
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 IncomingMessage.<anonymous> (/home/ec2-user/environment/node_modules/request/request.js:1085:12)
at IncomingMessage.g (events.js:292:16)
我尝试从我的主分支创建新实例(自上次工作以来没有提交),甚至仍然出现此错误。有什么想法吗?
导致错误的代码,尽管此代码以前正在使用。
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.com/${username}/status/${tweetId}`)
}
});
第一次出现的图像。正如你可以看到一切运行正常,然后这个错误无处不在,绝对没有改变环境或代码库。
更新:
使用console.log('Try Favorite - ', err.message);
而不是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
另请注意,转推功能使用相同的控制台记录方法。请参阅下面的代码,输出正常。
// try retweet
T.post('statuses/retweet', id, function(err, response){
// log failures
if(err){
console.log('Try Retweet - ', err[0].message);
}