-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Add more retries to font fetching #53239
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
4769c4e
to
948a686
Compare
Can anyone review this? |
Signed-off-by: Sora Morimoto <sora@morimoto.io>
948a686
to
130e6f6
Compare
@shuding Could you check this? |
This PR should be superseded by #56583. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!