Requesting a large number of icons in a custom collection results in 431 / 414
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- nuxt, typescript
- Domain
- frontend
Research direction
Start by inspecting dist/runtime/plugin.js and the customIconLoader path described in the issue. Reproduce the icon picker request with roughly 1,500 icons, then verify that the requests stay within URL limits and the combined response retains the expected prefix and icons without 431 or 414 errors.
Written by the indexing model from the issue text.
Description
I included Fontawesome v5 as a custom collection and for most parts of the project, only statically known icons are used which get bundled in the client bundle. however, there is an icon picker which needs all icons loaded. thus, the client sends a single request with ~1500 icons to the server route. as it is a GET request, this exceeds some server limits. I saw both 431 (Request Header Fields Too Large) and 414 (URI Too Long).
However, I am able to work around this by patching @nuxt/icon. It is not a polished implementation as it has a hardcoded chunk size and a possibly-faulty reduce e.g. when prefix differs across requests.
Another solution would be to use a different method and send the icons via body, but I assume this makes caching a lot harder.
diff --git a/dist/runtime/plugin.js b/dist/runtime/plugin.js
index f28e510a0241337ccd4faec7e0cb70a0185ad6de..df38295bc45dc8f7bc4e7bedfb007459b8bf6e85 100644
--- a/dist/runtime/plugin.js
+++ b/dist/runtime/plugin.js
@@ -25,11 +25,22 @@ export default defineNuxtPlugin({
}
async function customIconLoader(icons, prefix) {
try {
- const data = await requestFetch(resources[0] + "/" + prefix + ".json", {
- query: {
- icons: icons.join(",")
- }
- });
+ // when requesting many icons, split request into several to prevent too long header values / uri (431 / 414)
+ const chunkSize = 1000;
+ const requests = [];
+ while (requests.length * chunkSize < icons.length) {
+ const chunk = icons.slice(requests.length * chunkSize, (requests.length + 1) * chunkSize).join(",");
+ requests.push(requestFetch(resources[0] + "/" + prefix + ".json", {
+ query: {
+ icons: chunk
+ }
+ }));
+ }
+ const data = (await Promise.all(requests))
+ .reduce((acc, item) => ({
+ ...acc,
+ icons: {...acc.icons, ...item.icons},
+ }));
if (!data || data.prefix !== prefix || !data.icons)
throw new Error("Invalid data" + JSON.stringify(data));
return data;
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 96
- Avg merge
- 8h 12m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nuxt/icon
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·