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

Update PDF util #4742

Merged
merged 1 commit into from Oct 22, 2020
Merged

Update PDF util #4742

merged 1 commit into from Oct 22, 2020

Conversation

sbinlondon
Copy link
Contributor

  • Adds new util fetchWithTimeout which takes a URL and options to pass to node-fetch and a timeout in ms, and returns a thenable promise
  • Uses the timeout when fetching PDFs for thank you emails
  • Does not send PDF receipt for gift card transactions

* @param {Number} [timeoutInMs] The callback to call with the authorized client. Default is 5000 ms.
*/

export const fetchWithTimeout = (fetchParams, timeoutInMs = 5000) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would look better by following fetch API: first argument url, second argument options. timeoutInMs could be read from options or kept as third argument.

Copy link
Member

@Betree Betree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper looks good to me, using async/await may have been cleaner - promises chains are a bit difficult to read. But that's not a blocker.

server/lib/payments.js Outdated Show resolved Hide resolved
server/lib/pdf.js Outdated Show resolved Hide resolved
@sbinlondon
Copy link
Contributor Author

The helper looks good to me, using async/await may have been cleaner - promises chains are a bit difficult to read. But that's not a blocker.

I'll keep this in mind and maybe refactor next week when I have a bit more time. Was good to practice promises at least 😅

server/lib/fetch.js Outdated Show resolved Hide resolved
Copy link
Member

@znarf znarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm not sure if that's needed but we could also add Keep-Alive.

Similar to https://github.com/opencollective/opencollective-frontend/blob/master/lib/apollo-client.js#L49

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 this pull request may close these issues.

None yet

3 participants