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

Throw previous error if there's a timeout #57

Open
cdeevfrr opened this issue Nov 4, 2019 · 2 comments
Open

Throw previous error if there's a timeout #57

cdeevfrr opened this issue Nov 4, 2019 · 2 comments

Comments

@cdeevfrr
Copy link

cdeevfrr commented Nov 4, 2019

Right now, code like this will actually throw the error 'RetryOperation timeout occurred' which originates in node-retry. It should throw the error I made ("HI" + Math.random()), but doesn't because of a timeout error.

import * as retry from 'async-retry'

async function throwsErrors(){
  await delay(1000)
  throw new Error("HI" + Math.random())
}

retry(
  async (bail, attempt) => {
      await throwsErrors()
  } , {
    maxRetryTime: 100,
    minTimeout: 2,
    randomize: true,
    retries: 100,
    onRetry: console.log
  }
).then(console.log)

async function delay(milliseconds: number) {
  return new Promise(resolve => setTimeout(resolve, milliseconds))
}

I made an issue in node-retry that describes why this happens in detail, but the gist is that if you call retryOperation.retry(err) and there's a timeout error, node-retry drops err. I'm not sure if this is something that node-retry needs to support or if it's something that you can/should handle here.

@cdeevfrr
Copy link
Author

cdeevfrr commented Nov 5, 2019

We created this PR on node-retry, though I'm not sure how long it'll take until it gets looked at
tim-kos/node-retry#71

@cdeevfrr
Copy link
Author

cdeevfrr commented Mar 3, 2020

Has anyone had a chance to look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant