Skip to content

Commit 544d128

Browse files
authored
fix: Treat 304 as an ok response when downloading fonts (#2345)
1 parent 277bade commit 544d128

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/compass/scripts/download-akzidenz.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ const download = async(url, destDir) => {
6767

6868
const res = await fetch(url);
6969

70-
if (!res.ok) {
70+
// If cache item stored by `make-fetch-happen` is stale, it will check if
71+
// resource was not modified with the remote and can return a 304 with a body
72+
// present. In that case we don't want to throw an error, but rather proceed
73+
// with the normal flow
74+
if (!res.ok && res.status !== 304) {
7175
throw new Error(`Failed to fetch ${url}: ${res.statusText}`);
7276
}
7377

scripts/download-akzidenz.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ const download = async (url, destDir) => {
5656

5757
const res = await fetch(url);
5858

59-
if (!res.ok) {
59+
// If cache item stored by `make-fetch-happen` is stale, it will check if
60+
// resource was not modified with the remote and can return a 304 with a body
61+
// present. In that case we don't want to throw an error, but rather proceed
62+
// with the normal flow
63+
if (!res.ok && res.status !== 304) {
6064
throw new Error(`Failed to fetch ${url}: ${res.statusText}`);
6165
}
6266

0 commit comments

Comments
 (0)