-
Notifications
You must be signed in to change notification settings - Fork 491
-
Notifications
You must be signed in to change notification settings - Fork 491
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
[useStorage] getItem and getItemRaw -> Inconsistent behaviour between dev and preview/production #2666
Comments
Whlite investigating, I found this related set of file extensions here: nitro/src/rollup/plugins/raw.ts Line 10 in af42c19
Appart from the issue described above, it might be useful to provide a way to edit this list through some config options to allow devs to choose how to handle custom file assets. If there already is a way, I could not figure it out. |
I also encountered this difference using Nuxt today. In production you can get the string with a TextDecoder:
But yes, the behavior should be equal in all environments. Because in dev this will throw an error |
I spent some time on this today. Actually the problem (or solution) is not the extension array which is used in the resolveId method. The culprit is the So I found 3 workarounds to fix this for sql files:
|
Environment
Operating System: Windows_NT
Node Version: v22.6.0
Nuxt Version: 3.12.4
Nitro Version: 2.9.7
Package Manager: [email protected]
Builder: vite
User Config: devtools, compatibilityVersion : 4
Runtime Modules: -
Build Modules: -
Context: Following "Assets" section in Nitro documentation to handle SQL files.
Reproduction
1 - Create server/assets/demo.sql with:
2 - Create server/routes/test.get.ts with:
3 - Build the app and fetch this api both in dev and preview mode -> Results are inconsistents.
Describe the bug
Here is the result in dev mode:
Here is the result in preview/production:
=> Results should be the same between dev and production mode.
In my particular case, those differences lead to database fetching error.
Additional context
Here is the content of .output/server/chunks/raw/demo.mjs:
Here is the content of .output/server/chunks/raw/demo.mjs if I rename demo.sql to demo.txt:
The problem appears using whatever unsupported file extension leading to base64 encoding on build output.
No problem with txt, html or json files. Files with no extension can be retreived with getItem( ) in dev mode but are purely ignored from build (not present).
Also, might be related to #1926 and #2481
Logs
No response
The text was updated successfully, but these errors were encountered: