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

Add options parameter to beforeRetry hook #2295

Open
1 task done
JaneJeon opened this issue Sep 3, 2023 · 1 comment
Open
1 task done

Add options parameter to beforeRetry hook #2295

JaneJeon opened this issue Sep 3, 2023 · 1 comment

Comments

@JaneJeon
Copy link
Contributor

JaneJeon commented Sep 3, 2023

What problem are you trying to solve?

I am trying to write a hook that (automatically) first tries an HTTPS version of a website, and then if it fails, retries it without forcing the HTTPS version.

This is currently not possible to do as a got plugin, as in the control flow of "beforeRequest forces HTTPS" -> "request fails" -> "beforeRetry sets a flag to not force HTTPS" -> "beforeRequest doesn't force HTTPS this time" -> "request sent", you cannot "send" information between the beforeRetry hook and the second invocation of beforeRequest hook, due to the beforeRetry hook not having options as a parameter, which is used everywhere else in got's ecosystem to pass around information between hooks.

(note that afterResponse doesn't cut it because the request may throw - not just return a 4xx/5xx - when requesting a https version of a website (e.g. the certs may throw).

Describe the feature

Please add a third parameter, options, to the beforeRetry hooks. That's it.

Checklist

  • I have read the documentation and made sure this feature doesn't already exist.
@Rand0mF
Copy link

Rand0mF commented Jan 5, 2024

@JaneJeon the options property was removed since got 12, but it is still available with error.options
See changelog

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

2 participants