Skip to content

Uncaught promise rejection causing program to crash #218

Description

@richardkazuomiller

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v10Spotify-api.js v10

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions