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

doc: clarify Web Storage behavior #53871

Closed
cjihrig opened this issue Jul 16, 2024 · 10 comments
Closed

doc: clarify Web Storage behavior #53871

cjihrig opened this issue Jul 16, 2024 · 10 comments
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors.

Comments

@cjihrig
Copy link
Contributor

cjihrig commented Jul 16, 2024

Affected URL(s)

https://nodejs.org/api/globals.html, https://nodejs.org/api/cli.html

Description of the problem

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.

For reference, here are the Deno docs on Web Storage.

@cjihrig cjihrig added doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. labels Jul 16, 2024
@ameer-w-ali
Copy link

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
Copy link
Contributor Author

cjihrig commented Jul 16, 2024

We don't typically assign issues. If you want to work on this, just open a PR 😄

@Rekl0w
Copy link
Contributor

Rekl0w commented Jul 17, 2024

PR submitted.

@jakecastelli
Copy link
Member

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.rs here, in nodejs the closest thing I could find its SQLITE_CONSTRAINT is 19 which means /* Abort due to constraint violation */, maybe I missed something.

@cjihrig
Copy link
Contributor Author

cjihrig commented Jul 18, 2024

Sure. It comes from here.

@jakecastelli
Copy link
Member

Ohh I see, thanks! A follow up question, should there be a test case for it?

@cjihrig
Copy link
Contributor Author

cjihrig commented 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
Copy link
Member

jakecastelli commented 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
Copy link
Contributor Author

cjihrig commented 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.

jakecastelli added a commit that referenced this issue Aug 2, 2024
PR-URL: #53964
Refs: #53871
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
targos pushed a commit that referenced this issue Aug 14, 2024
PR-URL: #53964
Refs: #53871
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
@cjihrig
Copy link
Contributor Author

cjihrig commented Sep 20, 2024

Closed by #53881

@cjihrig cjihrig closed this as completed Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors.
Projects
None yet
Development

No branches or pull requests

4 participants