No Error when you have 0 balance

How can I receive an error, such as a 429 error? this code starts to endlessly load:

return new Promise((resolve, reject) => {
      openai.beta.threads.runs
        .createAndStream(threadId, {
          assistant_id
        })
        .on('textDone', (text) => {
          try {
            // ...
          } catch (error) {
            console.error(error);
            reject(error);
          }
        })
        .on('error', (error) => {
          reject(error);
        });
    });

See:

Rate Limits and 429: ‘Too Many Requests’ Errors

OpenAI has recently been allowing accounts to run into negative credits for a long time after $0.00 before being shut off. The hard limit also seems non-functional.

So if you want to see that your code will return an error when receiving that error, even though YOU don’t when the API should, you might need to make a new account without funds.

And don’t count on the API function to stop the account from going -$1000.00, as has been reported.

Hi!
You should start by making sure that you are actually catching the errors.
From the docs:
https://platform.openai.com/docs/guides/error-codes/handling-errors

Then you can look into possible solutions for this specific case.
In the OpenAI cookbook is also an example to provoke and resolve a 429 error.
Please make sure you aren’t spending all your credits on debugging.