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 a basic retry on fetch #43

Closed
coletdjnz opened this issue Dec 26, 2024 · 2 comments · Fixed by #44
Closed

Add a basic retry on fetch #43

coletdjnz opened this issue Dec 26, 2024 · 2 comments · Fixed by #44

Comments

@coletdjnz
Copy link
Contributor

fetch: async (url: any, options: any): Promise<any> => {
try {
const response = await axios.post(url, options.body, {
headers: {
...options.headers,
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
},
httpsAgent: dispatcher,
});
return {
ok: true,
json: async () => {
return response.data;
},
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return {
ok: false,
json: async () => {
return null;
},
};
}
},

Currently if there is a brief network issue or outage, these requests may fail causing an HTTP 500 to be received on yt-dlp end and no PO Token added to the request.

Perhaps a basic retry (with a limit) could be added to requests (e.g. retry 3 times before giving up)?

@Brainicism
Copy link
Owner

@coletdjnz
Adding retries as part of #44
Do you think your plugin framework should also attempt a retry if not PO token was received from the provider? Or at least throw a specific error so that the user knows what happened.

@coletdjnz
Copy link
Contributor Author

Do you think your plugin framework should also attempt a retry if not PO token was received from the provider?

I think this would be up to the provider plugin to implement, as it is dependent on the implementation whether it can be retried or not.

Or at least throw a specific error so that the user knows what happened.

It does raise a warning if a RequestError is thrown

@grqz grqz closed this as completed in #44 Dec 27, 2024
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

Successfully merging a pull request may close this issue.

2 participants