Skip to content

Commit

Permalink
feat: Support parallel snapshots calls (#168)
Browse files Browse the repository at this point in the history
* Fix parallel builds

When parallel builds occur there is the posibility that the same
assets will be triggerd on the same pooled page, this means that there
is a likely outcome that the resource will be intercepted and handled
twice, this is illegal with puppeteer.

Polling available pages up to 10 is also memory intensive for sequential
builds as 10 pages will be in memory. This can cause issues in low
memory enviroments.

- Remove pooling and open close pages on demand to reduce memory
footprint
- Open new page on demand to ensure that parallel builds that request
same resource do not conflict which causes the puppeteer to throw up
error that request is already handled.
- Add catch clauses around request interception to ensure that e2e tests
continue if there is an issue with percy.

* Create page pool for sequential builds only

Add page pool for sequential builds, to reduce execution overhead when
creating new page

- Add checks to detirmine sequential build to create page pool at setup
- Add checks to ensure page pool has been setup for sequential build

* Use generic-pool

Use generic pool to create a pool for both parallel builds and serial
builds. The pool will create page instances on demand, releasing them
after requests are finished.

* Update naming

- Rename pool to pagePool
- Create constants for the page pool size with configuration via env
variable

* Add test to capture multiple snapshots fired at once
  • Loading branch information
blake-newman authored and djones committed May 30, 2019
1 parent ca74f3d commit 744a399
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 79 deletions.
51 changes: 31 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"cors": "^2.8.4",
"cross-spawn": "^6.0.5",
"express": "^4.16.3",
"generic-pool": "^3.7.1",
"globby": "^9.2.0",
"js-yaml": "^3.13.1",
"percy-client": "^3.0.3",
Expand All @@ -54,6 +55,7 @@
"@types/chai-http": "^3.0.5",
"@types/cors": "^2.8.4",
"@types/cross-spawn": "^6.0.0",
"@types/generic-pool": "^3.1.9",
"@types/http-server": "^0.10.0",
"@types/mocha": "^5.2.5",
"@types/nock": "^10.0.2",
Expand Down
Loading

0 comments on commit 744a399

Please sign in to comment.