Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught promise rejection causing program to crash #218

Open
1 of 2 tasks
richardkazuomiller opened this issue Mar 9, 2023 · 1 comment
Open
1 of 2 tasks

Uncaught promise rejection causing program to crash #218

richardkazuomiller opened this issue Mar 9, 2023 · 1 comment
Labels
v10 Spotify-api.js v10

Comments

@richardkazuomiller
Copy link

richardkazuomiller commented Mar 9, 2023

Bug Report

Since

this._init(options);
is not awaited or called with .catch(...) after it, Node will exit if the promise returned by this._init() rejects.

It's a bit tricky because it is called in the constructor which means we can't just add await in front of it and I don't know enough about the codebase to suggest how to refactor it at the moment.

What i expected:

A failed API request should not make the process exit.

What actually happened:

A bad response when trying to refresh the token causes the process to exit

/Users/richardmiller/srv/ricky-js-monorepo/node_modules/axios/lib/core/settle.js:19
    reject(new AxiosError(
           ^
AxiosError: Request failed with status code 503
    at settle (/Users/richardmiller/srv/ricky-js-monorepo/node_modules/axios/lib/core/settle.js:19:12)
    at Unzip.handleStreamEnd (/Users/richardmiller/srv/ricky-js-monorepo/node_modules/axios/lib/adapters/http.js:548:11)
    at Unzip.emit (node:events:538:35)
    at Unzip.emit (node:domain:475:12)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ERR_BAD_RESPONSE',
  (... removed unrelated stuff ...)
    url: 'https://accounts.spotify.com/api/token',
    params: {
      grant_type: 'refresh_token',
      code: undefined,
  (... removed unrelated stuff ...)

To reproduce this bug:

Difficult to reproduce because it is caused by 503 from Spotify.

  • Node Version:

  • Library Version:

  • I have already checked issues regarding this bug.

  • This problem is generated due to version migration.

@scientific-dev
Copy link
Member

You don't have to worry about the promise rejection in _init function there as the _init function involves a try catch statement. If there are any errors thrown, it is the SpotifyAPIError or the AxiosError. The package uses endpoints, resources for few endpoints are outdated as the spotify api has changed its few structures.

As i am the only one maintaining the module, it will take some time to fix this (probably more than a month). It would be better if you send the code which led to the error.

@scientific-dev scientific-dev added the v10 Spotify-api.js v10 label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v10 Spotify-api.js v10
Projects
None yet
Development

No branches or pull requests

2 participants