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

fix(preview-service): only create a puppeteer client per app, not per request #2899

Merged
merged 2 commits into from
Sep 7, 2024

Conversation

iainsproat
Copy link
Contributor

@iainsproat iainsproat commented Sep 6, 2024

Description & motivation

It looked wrong and I left a comment next to it that it looked wrong. Turns out it was wrong.

The puppeteer client should exist over the lifetime of the app. If it is created on each request, firstly that's expensive and time consuming to create but secondly it creates a conflict if another request is made while the first is still ongoing.

Changes:

  • puppeteer client is created at app instantiation. It is passed in to the express server.
  • in tests a stub client is created and passed in.

To-do before merge:

Screenshots:

Validation of changes:

Checklist:

  • My pull request follows the guidelines in the Contributing guide?
  • My pull request does not duplicate any other open Pull Requests for the same update/change?
  • My commits are related to the pull request and do not amend unrelated code or documentation.
  • My code follows a similar style to existing code.
  • I have added appropriate tests.
  • I have updated or added relevant documentation.

References

@iainsproat iainsproat changed the title fix(preview-service): only create a puppeteer client per app, not per… fix(preview-service): only create a puppeteer client per app, not per request Sep 7, 2024
@iainsproat iainsproat marked this pull request as ready for review September 7, 2024 08:49
@iainsproat iainsproat merged commit d5c9e5e into main Sep 7, 2024
25 of 27 checks passed
@iainsproat iainsproat deleted the iain/fix-preview-service-puppeteer-singleton branch September 7, 2024 08:50
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.

1 participant