nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
961 stars 59 forks source link

Cache keys may be too long and throw ENAMETOOLONG #260

Closed stafyniaksacha closed 1 month ago

stafyniaksacha commented 2 months ago

Using multiple icons of the same provider will grow cache key length as described here: https://github.com/nuxt/icon/blob/7cb5ade2057699c2fb132afc29353e45f629490b/src/runtime/server/api.ts#L72-L76

The issue is that it can trigger ENAMETOOLONG error if the key is larger than the OS can handle, raising:

 ERROR  [nitro] [cache] Cache write error. ENAMETOOLONG: name too long, open '/home/stf/projects/laast/laast-io-monorepo/apps/frontend/.nuxt/cache/nuxt/icon/ph_bankduotone_calculatorduotone_calendarblankduotone_calendardotsduotone_chartpiesliceduotone_chatduotone_gearduotone_lifebuoyduotone_packageduotone_sealcheckduotone_squarehalfduotone_stackduotone_storefrontduotone_timerduotone_usersduotone_wrenchduotone.json'

  at async open (node:internal/fs/promises:639:25)
  at async Object.writeFile (node:internal/fs/promises:1219:14)
  at async Object.setItem (/home/stf/projects/laast/laast-io-monorepo/node_modules/.pnpm/unstorage@1.12.0_ioredis@5.4.1/node_modules/unstorage/dist/index.mjs:205:7)

Maybe using ohash can be a solution?

Simlor commented 1 month ago

+1

antfu commented 1 month ago

Should be fixed in v1.5.4