InfluxCommunity / influxdb3-js

The JavaScript Client that provides a simple and convenient way to interact with InfluxDB 3.
https://influxcommunity.github.io/influxdb3-js/
MIT License
13 stars 4 forks source link

Add Headers to HttpError #357

Closed PrestonGiorgianni closed 1 month ago

PrestonGiorgianni commented 2 months ago

Use Case

The api documentation for the api indicates that when you get a 429 rate limit, you should look at the Retry-After to determine when to try the request again. Currently influxClient.write will throw an error on 429 status codes, but I do not have access to this header to know how long to wait before a retry.

Expected behavior

try {
  influxClient.write(...)
} catch(error) {
  if (error instanceof HttpError && error.statusCode === 429) {
    error.headers['Retry-After'] !== undefined; //should be truthy
    // some back off logic based on error.headers['Retry-After']
  }
}

Actual behavior

try {
  influxClient.write(...)
} catch(error) {
  if (error instanceof HttpError && error.statusCode === 429) {
    error.headers['Retry-After'] !== undefined; //is falsy
    // some back off logic based on error.headers['Retry-After']
  }
}

Additional info

No response

bednar commented 2 months ago

Hi @PrestonGiorgianni,

Thank you for reporting this. We will address it as soon as possible.

Is this something you would be willing to help with? All PR is welcome and we will be happy to review your submission.

Regards