Sitelet https://github.com/nodejs/node/issues/53871
Skip to content

doc: clarify Web Storage behavior #53871

Description

@cjihrig

Affected url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2Fs)

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.

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    good first issueIssues that are suitable for first-time contributors.
    on Jul 16, 2024
  2. ameer-w-ali commented on Jul 16, 2024

    @ameer-w-ali

    Hello sir, can you assign this Issue to me. I want to start my contribution journey and I think I can handle this issue

  3. cjihrig commented on Jul 16, 2024

    @cjihrig
    ContributorAuthor

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

  4. Rekl0w commented on Jul 17, 2024

    @Rekl0w
    Contributor

    PR submitted.

  5. jakecastelli commented on Jul 18, 2024

    @jakecastelli
    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.

  6. cjihrig commented on Jul 18, 2024

    @cjihrig
    ContributorAuthor

    Sure. It comes from here.

  7. jakecastelli commented on Jul 18, 2024

    @jakecastelli
    Member

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

  8. cjihrig commented on Jul 18, 2024

    @cjihrig
    ContributorAuthor

    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.

  9. jakecastelli commented on Jul 18, 2024

    @jakecastelli
    Member

    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 🙏

  10. cjihrig commented on Jul 18, 2024

    @cjihrig
    ContributorAuthor

    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.

  11. added a commit that references this issue on Aug 14, 2024
  12. cjihrig commented on Sep 20, 2024

    @cjihrig
    ContributorAuthor

    Closed by #53881

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions