apify / apify-client-js

Apify API client for JavaScript / Node.js.
https://docs.apify.com/api/client/js
Apache License 2.0
67 stars 27 forks source link

Better logging of errors on missed exponential backoff #77

Closed jancurn closed 5 years ago

jancurn commented 6 years ago

For example, on RequestQueue throttling errors we get in log the following message, which doesn't actually tell anything about what happened. These errors are incorrectly reported by server as 502, which will be fixed in upcoming deploy. But still, we should show more info.

2018-08-11T01:55:13.304Z ApifyError: Server request failed with 9 tries.
2018-08-11T01:55:13.306Z     at Request._request2.default.(anonymous function) [as _callback] (/home/myuser/node_modules/apify-client/build/utils.js:142:35)
2018-08-11T01:55:13.308Z     at Request.self.callback (/home/myuser/node_modules/request/request.js:185:22)
2018-08-11T01:55:13.311Z     at emitTwo (events.js:126:13)
2018-08-11T01:55:13.313Z     at Request.emit (events.js:214:7)
2018-08-11T01:55:13.316Z     at Request.<anonymous> (/home/myuser/node_modules/request/request.js:1157:10)
2018-08-11T01:55:13.318Z     at emitOne (events.js:116:13)
2018-08-11T01:55:13.320Z     at Request.emit (events.js:211:7)
2018-08-11T01:55:13.322Z     at IncomingMessage.<anonymous> (/home/myuser/node_modules/request/request.js:1079:12)
2018-08-11T01:55:13.324Z     at Object.onceWrapper (events.js:313:30)
2018-08-11T01:55:13.326Z     at emitNone (events.js:111:20)
2018-08-11T01:55:13.328Z     at IncomingMessage.emit (events.js:208:7)
2018-08-11T01:55:13.330Z     at endReadableNT (_stream_readable.js:1064:12)
2018-08-11T01:55:13.333Z     at _combinedTickCallback (internal/process/next_tick.js:138:11)
2018-08-11T01:55:13.339Z     at process._tickCallback (internal/process/next_tick.js:180:9)
jancurn commented 6 years ago

BTW we should replace promise-chains with async/await wherever possible, which will automagically improve the error messages.

mtrunkat commented 5 years ago

Done.