Skip to content
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

Cache keys may be too long and throw ENAMETOOLONG #260

Closed
stafyniaksacha opened this issue Sep 26, 2024 · 2 comments
Closed

Cache keys may be too long and throw ENAMETOOLONG #260

stafyniaksacha opened this issue Sep 26, 2024 · 2 comments

Comments

@stafyniaksacha
Copy link

Using multiple icons of the same provider will grow cache key length as described here:

getKey(event: H3Event) {
const collection = event.context.params?.collection?.replace(/\.json$/, '') || 'unknown'
const icons = String(getQuery(event).icons || '').split(',')
return `${collection}_${icons.join('_')}`
},

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?

@stafyniaksacha stafyniaksacha changed the title Cache keys on windows may be too long Cache keys may be too long Sep 26, 2024
@stafyniaksacha stafyniaksacha changed the title Cache keys may be too long Cache keys may be too long and throw ENAMETOOLONG Sep 26, 2024
@Simlor
Copy link

Simlor commented Oct 5, 2024

+1

@antfu
Copy link
Member

antfu commented Oct 6, 2024

Should be fixed in v1.5.4

@antfu antfu closed this as completed Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants