Sneezry / leetpress

MIT License
15 stars 0 forks source link

Resolve http redirect, such as 302. #2

Closed STRRL closed 5 years ago

STRRL commented 5 years ago

Output:

Error occured. Please open LeetCode with browser to check if problem loads correctly, then run again.
(node:20) UnhandledPromiseRejectionWarning: StatusCodeError: 302 - "<html>\r\n<head><title>302 Found</title></head>\r\n<body>\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.15.6</center>\r\n</body>\r\n</html>\r\n"
    at new StatusCodeError (/leetpress/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/leetpress/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/leetpress/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/leetpress/node_modules/request/request.js:185:22)
    at Request.emit (events.js:198:13)
    at Request.<anonymous> (/leetpress/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:198:13)
    at IncomingMessage.<anonymous> (/leetpress/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:286:20)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:20) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:20) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Except: Follow the redirect and download as usual.

Actual: Programe exit.

Sneezry commented 5 years ago

LeetCode returns 302 when you hit limit rate. Following redirect URL won't fix the issue. You need have a rest to wait LeetCode for removing you from forbidden list, and run LeetPress again.