Skip to content

🐛 Request fonts as binary via Node#921

Merged
Robdel12 merged 4 commits intomasterfrom
rd/font
May 12, 2022
Merged

🐛 Request fonts as binary via Node#921
Robdel12 merged 4 commits intomasterfrom
rd/font

Conversation

@Robdel12
Copy link
Copy Markdown
Contributor

@Robdel12 Robdel12 commented May 11, 2022

What is this?

Sometimes, through the SDKs, fonts are captured as corrupted. This has been a long standing problem in Percy's SDKs. It turns out we cannot trust the decoding the browser does in request interception with fonts -- a lot of the time those fonts network responses are already corrupted by the time our SDK wants to save the response body. For example, the left is current and the right is correct

fonts-broken

In order to work around this, we use Node to request the font files directly as binary data. This solves all issues we've seen with fonts being captured as corrupt.

This will resolve percy/percy-protractor#222, percy/percy-cypress#366, #790, & other issues like this.

Sometimes, through the SDKs, fonts are captured as corrupted. This has been a
long standing problem in Percy's SDKs. It turns out we cannot trust the decoding
the browser does in request interception with fonts -- a lot of the time those
fonts network responses are already corrupted by the time our SDK wants to save
the response body.

In order to work around this, we use Node to request the font files directly as
binary data. This solves all issues we've seen with fonts being captured as
corrupt.
@Robdel12 Robdel12 added the 🐛 bug Something isn't working label May 11, 2022
@Robdel12 Robdel12 marked this pull request as ready for review May 12, 2022 16:03
@Robdel12 Robdel12 requested a review from wwilsman May 12, 2022 16:03
Copy link
Copy Markdown
Contributor

@wwilsman wwilsman left a comment

Choose a reason for hiding this comment

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

Potential bug to fix. Your call if you wanna add another test for it. Other suggestions are just a personal opinion on the comments.

@Robdel12 Robdel12 requested a review from wwilsman May 12, 2022 17:03
Copy link
Copy Markdown
Contributor

@wwilsman wwilsman left a comment

Choose a reason for hiding this comment

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

🎮

@Robdel12 Robdel12 merged commit b31f437 into master May 12, 2022
@Robdel12 Robdel12 deleted the rd/font branch May 12, 2022 17:13
@fotinakis
Copy link
Copy Markdown
Contributor

🔥 this is fantastic, probably will fix a lot of tricky and hard to debug issues — well done!

kodiakhq bot referenced this pull request in carbon-design-system/carbon-for-ibm-dotcom May 24, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@percy/cli](https://togithub.com/percy/cli) | [`~1.1.0` -> `~1.2.0`](https://renovatebot.com/diffs/npm/@percy%2fcli/1.1.0/1.2.1) | [![age](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.2.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.2.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.2.1/compatibility-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.2.1/confidence-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) |
| [@percy/dom](https://togithub.com/percy/cli) | [`~1.1.0` -> `~1.2.0`](https://renovatebot.com/diffs/npm/@percy%2fdom/1.1.0/1.2.1) | [![age](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.2.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.2.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.2.1/compatibility-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.2.1/confidence-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) |
| [@percy/sdk-utils](https://togithub.com/percy/cli) | [`~1.1.0` -> `~1.2.0`](https://renovatebot.com/diffs/npm/@percy%2fsdk-utils/1.1.0/1.2.1) | [![age](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.2.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.2.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.2.1/compatibility-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.2.1/confidence-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>percy/cli</summary>

### [`v1.2.1`](https://togithub.com/percy/cli/releases/tag/v1.2.1)

[Compare Source](https://togithub.com/percy/cli/compare/v1.2.0...v1.2.1)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### 🐛 Bug Fixes

-   🐛 Fix sitemap xml parsing regex (stop when the lookahead matches) by [@&#8203;Robdel12](https://togithub.com/Robdel12) in [https://github.com/percy/cli/pull/928](https://togithub.com/percy/cli/pull/928)

**Full Changelog**: percy/cli@v1.2.0...v1.2.1

### [`v1.2.0`](https://togithub.com/percy/cli/releases/tag/v1.2.0)

[Compare Source](https://togithub.com/percy/cli/compare/v1.1.4...v1.2.0)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### ✨ Enhancements

-   ✨ Add additional snapshot command exec helpers by [@&#8203;wwilsman](https://togithub.com/wwilsman) in [https://github.com/percy/cli/pull/922](https://togithub.com/percy/cli/pull/922)

##### 🐛 Bug Fixes

-   🐛 Fix regex matching accepting non-regex patterns by [@&#8203;wwilsman](https://togithub.com/wwilsman) in [https://github.com/percy/cli/pull/923](https://togithub.com/percy/cli/pull/923)

##### ⬆️⬇️ Dependency Updates

-   ⬆️ Bump karma from 6.3.19 to 6.3.20 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/927](https://togithub.com/percy/cli/pull/927)
-   ⬆️ Bump yaml from 2.0.1 to 2.1.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/925](https://togithub.com/percy/cli/pull/925)
-   ⬆️ Bump karma-jasmine from 5.0.0 to 5.0.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/926](https://togithub.com/percy/cli/pull/926)

**Full Changelog**: percy/cli@v1.1.4...v1.2.0

### [`v1.1.4`](https://togithub.com/percy/cli/releases/tag/v1.1.4)

[Compare Source](https://togithub.com/percy/cli/compare/v1.1.3...v1.1.4)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### 🐛 Bug Fixes

-   🐛 Request fonts as binary via Node by [@&#8203;Robdel12](https://togithub.com/Robdel12) in [https://github.com/percy/cli/pull/921](https://togithub.com/percy/cli/pull/921)

**Full Changelog**: percy/cli@v1.1.3...v1.1.4

### [`v1.1.3`](https://togithub.com/percy/cli/releases/tag/v1.1.3)

[Compare Source](https://togithub.com/percy/cli/compare/v1.1.2...v1.1.3)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### 🐛 Bug Fixes

-   🐛 Fix sdk-utils test helper log capture by [@&#8203;wwilsman](https://togithub.com/wwilsman) in [https://github.com/percy/cli/pull/920](https://togithub.com/percy/cli/pull/920)

##### ⬆️⬇️ Dependency Updates

-   ⬆️ Bump path-to-regexp from 6.2.0 to 6.2.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/919](https://togithub.com/percy/cli/pull/919)
-   ⬆️ Bump rollup from 2.71.1 to 2.72.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/918](https://togithub.com/percy/cli/pull/918)

**Full Changelog**: percy/cli@v1.1.2...v1.1.3

### [`v1.1.2`](https://togithub.com/percy/cli/releases/tag/v1.1.2)

[Compare Source](https://togithub.com/percy/cli/compare/v1.1.1...v1.1.2)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### 🐛 Bug Fixes

-   🐛 Fix logger TTY logic for logging progress by [@&#8203;wwilsman](https://togithub.com/wwilsman) in [https://github.com/percy/cli/pull/917](https://togithub.com/percy/cli/pull/917)

**Full Changelog**: percy/cli@v1.1.1...v1.1.2

### [`v1.1.1`](https://togithub.com/percy/cli/releases/tag/v1.1.1)

[Compare Source](https://togithub.com/percy/cli/compare/v1.1.0...v1.1.1)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### 🐛 Bug Fixes

-   🐛 Rollback sdk-utils to commonjs for broader compatibility by [@&#8203;wwilsman](https://togithub.com/wwilsman) in [https://github.com/percy/cli/pull/916](https://togithub.com/percy/cli/pull/916)

##### ⬆️⬇️ Dependency Updates

-   ⬆️ Bump karma from 6.3.18 to 6.3.19 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/900](https://togithub.com/percy/cli/pull/900)
-   ⬆️ Bump [@&#8203;babel/preset-env](https://togithub.com/babel/preset-env) from 7.16.11 to 7.17.10 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/913](https://togithub.com/percy/cli/pull/913)
-   ⬆️ Bump rollup from 2.70.2 to 2.71.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/912](https://togithub.com/percy/cli/pull/912)
-   ⬆️ Bump [@&#8203;babel/cli](https://togithub.com/babel/cli) from 7.17.6 to 7.17.10 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/911](https://togithub.com/percy/cli/pull/911)
-   ⬆️ Bump ws from 8.5.0 to 8.6.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/914](https://togithub.com/percy/cli/pull/914)
-   ⬆️ Bump [@&#8203;babel/core](https://togithub.com/babel/core) from 7.17.9 to 7.17.10 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/910](https://togithub.com/percy/cli/pull/910)
-   ⬆️ Bump [@&#8203;rollup/plugin-node-resolve](https://togithub.com/rollup/plugin-node-resolve) from 13.2.1 to 13.3.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in [https://github.com/percy/cli/pull/915](https://togithub.com/percy/cli/pull/915)

**Full Changelog**: percy/cli@v1.1.0...v1.1.1

</details>

---

### Configuration

📅 **Schedule**: "every weekend" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/carbon-design-system/carbon-for-ibm-dotcom).
Robdel12 added a commit that referenced this pull request Jun 30, 2022
In #921 we realized font responses were being corrupted through the browsers request interception API. To get around that, we now request and save fonts straight from node as a binary (no encoding). In that PR, I forgot to pass the auth config to the request that's being made, which will prevent sites behind auth from capturing fonts properly.

This PR adds the request headers the browser has to the node request we made to capture the fonts directly. Also adds a debug log when we are requesting these fonts directly.

Closes #969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Woff fonts missing (corrupt on asset discovery capture)

3 participants