node-plex-api icon indicating copy to clipboard operation
node-plex-api copied to clipboard

Runtime.UnhandledPromiseRejection: StatusCodeError: 401

Open clarkd opened this issue 2 years ago • 0 comments

I'm trying to use plex-api from an AWS Lambda but it's failing with the below error.

"Runtime.UnhandledPromiseRejection: StatusCodeError: 401 - {\"type\":\"Buffer\",\"data\":[60,104,116,109,108,62,60,104,101,97,100,62,60,115,99,114,105,112,116,62,119,105,110,100,111,119,46,108,111,99,97,116,105,111,110,32,61,32,119,105,110,100,111,119,46,108,111,99,97,116,105,111,110,46,104,114,101,102,46,109,97,116,99,104,40,47,40,94,46,43,92,47,41,91,94,92,47,93,42,36,47,41,91,49,93,32,43,32,39,119,101,98,47,105,110,100,101,120,46,104,116,109,108,39,59,60,47,115,99,114,105,112,116,62,60,116,105,116,108,101,62,85,110,97,117,116,104,111,114,105,122,101,100,60,47,116,105,116,108,101,62,60,47,104,101,97,100,62,60,98,111,100,121,62,60,104,49,62,52,48,49,32,85,110,97,117,116,104,111,114,105,122,101,100,60,47,104,49,62,60,47,98,111,100,121,62,60,47,104,116,109,108,62]}",
        "    at process.<anonymous> (/var/runtime/index.js:35:15)",
        "    at process.emit (events.js:400:28)",
        "    at /var/task/wrappedHandler.js:52009:33",
        "    at activeFireEvent (/var/task/wrappedHandler.js:52050:46)",
        "    at fireRejectionEvent (/var/task/wrappedHandler.js:52414:16)",
        "    at Promise2._notifyUnhandledRejection (/var/task/wrappedHandler.js:51859:11)",
        "    at Timeout.unhandledRejectionCheck [as _onTimeout] (/var/task/wrappedHandler.js:51818:25)",
        "    at listOnTimeout (internal/timers.js:557:17)",
        "    at processTimers (internal/timers.js:500:7)"

Is there a known issue using this package in that environment? From what I can see it does the following:

  • Performs a GET on the configured URL for Plex
  • Gets a 401 as no token has been fetched yet
  • Tries to do a POST to plex.tv to get a token
  • Blows up with that error

But what's strange is that error seems to be triggered by the earlier 401, even though it's caught/handled at that point. It's very peculiar! Does this package use an old version of request or something like that perhaps?

Thanks!

clarkd avatar Apr 07 '22 17:04 clarkd