Skip to content

Conversation

smorimoto
Copy link
Contributor

What?

Increase the number of attempts from 3 to 5.

Why?

Our team had introduced our own mechanism for retries even before this mechanism was introduced by #51890, and we had the sensation that 5 attempts would eliminate the potential for CI failure. But now it's 3 attempts, and in this case it's much better than nothing but still seems to fail sometimes. Too many retries may not be a good idea, but I feel that kicking CI over and over results in more computational resources being wasted.

How?

Just as the code says!

@ijjk ijjk added Font (next/font) Related to Next.js Font Optimization. type: next labels Jul 27, 2023
@ijjk
Copy link
Member

ijjk commented Jul 27, 2023

Allow CI Workflow Run

  • approve CI run for commit: 130e6f6

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@smorimoto smorimoto force-pushed the add-more-retries-font-fetch branch from 4769c4e to 948a686 Compare July 28, 2023 15:14
@smorimoto
Copy link
Contributor Author

Can anyone review this?

Signed-off-by: Sora Morimoto <sora@morimoto.io>
@smorimoto smorimoto force-pushed the add-more-retries-font-fetch branch from 948a686 to 130e6f6 Compare August 24, 2023 18:12
@smorimoto
Copy link
Contributor Author

@shuding Could you check this?

@smorimoto
Copy link
Contributor Author

This PR should be superseded by #56583.

@smorimoto smorimoto closed this Oct 16, 2023
@smorimoto smorimoto deleted the add-more-retries-font-fetch branch October 16, 2023 15:40
kodiakhq bot pushed a commit that referenced this pull request Oct 20, 2023
### What?
Add the same re-retrieval process for subseted font files of Google Font as for CSS files.

+ make use of [async-retry](https://github.com/vercel/async-retry)

### Why?
It was reported in #45080 that Japanese fonts such as Noto Sans JP were frequently `Failed to fetch`.
A retry process was added in #51890, but it did not resolve the issue completely ( #51890 (comment) ).

Here is my reproduction code with 13.5.5-canary.4 (please run locally).
https://stackblitz.com/edit/stackblitz-starters-n8zxlq?file=app%2Fpage.tsx

<details>
<summary>And my local error log is here(folded)</summary>

```
$ npm run -- dev

> nextjs@0.1.0 dev
> next dev

 ⚠ Port 3000 is in use, trying 3001 instead.
  ▲ Next.js 13.5.5-canary.4
  - Local:        http://localhost:3001

 ✓ Ready in 23.9s
 ○ Compiling /page ...
FetchError: request to https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFBEj757Y0rw_qMHVdbR2L8Y9QTJ1LwkRmR5GprQAe69m.4.woff2 failed, reason: 
    at ClientRequest.<anonymous> (/mnt/c/Users/berlysia/Downloads/stackblitz-starters-n8zxlq/node_modules/next/dist/compiled/node-fetch/index.js:1:65756)
    at ClientRequest.emit (node:events:514:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT'
}
 ⨯ Failed to download `Noto Sans JP` from Google Fonts. Using fallback font instead.

Failed to fetch `Noto Sans JP` from Google Fonts.}
FetchError: request to https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFBEj757Y0rw_qMHVdbR2L8Y9QTJ1LwkRmR5GprQAe69m.28.woff2 failed, reason: 
    at ClientRequest.<anonymous> (/mnt/c/Users/berlysia/Downloads/stackblitz-starters-n8zxlq/node_modules/next/dist/compiled/node-fetch/index.js:1:65756)
    at ClientRequest.emit (node:events:514:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT'
}
...(15 errors emitted)
```
</details>

I've found that the issue is not limited to fetching CSS, fetching subset font files is also failing.
By adding retry handling to the fetch of individual subseted font files as well, I (almost) never see `Failed to fetch` anymore.

The issue tends to become more apparent when downloading a larger number of subsetted fonts.
This suggests that the problem is more likely to occur with larger fonts, such as those designed for CJK languages.

### How?
Add the same re-retrieval process for subseted font files of Google Font as for CSS files.


Related to #51890 #53239 #45080 #53279
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Font (next/font) Related to Next.js Font Optimization. locked type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants