You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that we should clarify some behaviors of Web Storage in Node.js vs. browsers.
Session storage and local storage are both scoped to the current process (not individual users or server requests). This is important for applications like server side rendering.
Local storage uses the value of --localstorage-file as its origin.
Other things that would be good to note:
Local storage files can be accessed by multiple processes simultaneously.
The local storage quota is also 10MB. This is noted for session storage.
Hi Colin, a quick question here, I am trying to figure out where the 10MB quota comes from in node (if you don't mind pointing out for me).
Deno has its own implementation of webstorage api and the 10mb comes from const MAX_STORAGE_BYTES: usize = 10 * 1024 * 1024; in denoland/deno/ext/webstorage/lib.rshere, in nodejs the closest thing I could find its SQLITE_CONSTRAINT is 19 which means /* Abort due to constraint violation */, maybe I missed something.
There are WPT tests for both local and session storage. They don't test for a specific quota value though, as that part is left up to individual implementors.
I think I should've asked a bit more specific, should there be a test for testing 10mb quota in node? Given the fact it is up to individual implementors. Hope my question is not disturbing though 🙏
I guess it wouldn't hurt. I would recommend not doing repeated writes like the WPT tests though. That approach works because they don't know what the upper bound will be. Since we know Node's upper limit, we can do it in just a few writes.
Activity
ameer-w-ali commentedon Jul 16, 2024
Hello sir, can you assign this Issue to me. I want to start my contribution journey and I think I can handle this issue
cjihrig commentedon Jul 16, 2024
We don't typically assign issues. If you want to work on this, just open a PR 😄
Rekl0w commentedon Jul 17, 2024
PR submitted.
jakecastelli commentedon Jul 18, 2024
Hi Colin, a quick question here, I am trying to figure out where the 10MB quota comes from in node (if you don't mind pointing out for me).
Deno has its own implementation of
webstorageapi and the 10mb comes fromconst MAX_STORAGE_BYTES: usize = 10 * 1024 * 1024;indenoland/deno/ext/webstorage/lib.rshere, in nodejs the closest thing I could find itsSQLITE_CONSTRAINTis19which means/* Abort due to constraint violation */, maybe I missed something.cjihrig commentedon Jul 18, 2024
Sure. It comes from here.
jakecastelli commentedon Jul 18, 2024
Ohh I see, thanks! A follow up question, should there be a test case for it?
cjihrig commentedon Jul 18, 2024
There are WPT tests for both local and session storage. They don't test for a specific quota value though, as that part is left up to individual implementors.
jakecastelli commentedon Jul 18, 2024
Thanks for giving more context on the WPT tests!
I think I should've asked a bit more specific, should there be a test for testing 10mb quota in node? Given the fact it is up to individual implementors. Hope my question is not disturbing though 🙏
cjihrig commentedon Jul 18, 2024
I guess it wouldn't hurt. I would recommend not doing repeated writes like the WPT tests though. That approach works because they don't know what the upper bound will be. Since we know Node's upper limit, we can do it in just a few writes.
test: add coverage for webstorage quota
test: add coverage for webstorage quota
cjihrig commentedon Sep 20, 2024
Closed by #53881