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 #54652

Closed
wants to merge 4 commits into from

Conversation

jmsb02
Copy link
Contributor

@jmsb02 jmsb02 commented Aug 30, 2024

Title:

doc: clarify Web Storage behavior and document --localstorage-file option

Description:

Issue Resolved

This pull request addresses the issue outlined in #53871. The changes clarify the Web Storage behavior in Node.js and document the --localstorage-file option.

Changes Made

  1. cli.md: Added documentation for the --localstorage-file option.

    • Placed after the --max-old-space-size section.
    • Described how to use the --localstorage-file option to specify the file used for localStorage in Node.js.
    • Mentioned key considerations such as the possibility of concurrent access by multiple processes and the 10MB storage quota per process.

    Example documentation snippet added:

    ### --localstorage-file
    
    The `--localstorage-file` option specifies the file used for `localStorage` in Node.js.
    
    - This file can be accessed by multiple processes simultaneously, which might require implementing file locking or other synchronization mechanisms to ensure data integrity.
    - The storage quota for `localStorage` is 10MB per process.
  2. globals.md: Added a new section describing how localStorage and sessionStorage behave in Node.js.

    • Clarified that both are scoped to the current process.
    • Explained that the --localstorage-file flag determines the file used for localStorage.
    • Reiterated the 10MB per process storage quota.

    Example documentation snippet added:

    ## Web Storage API
    
    In Node.js, the `localStorage` and `sessionStorage` objects function differently compared to browsers or Deno:
    
    - Both `localStorage` and `sessionStorage` are scoped to the current process, not individual users or server requests. This is crucial for applications like server-side rendering.
    - `localStorage` uses the value of the `--localstorage-file` flag as its origin. This file can be accessed simultaneously by multiple processes, which may require implementing file locking or other synchronization mechanisms to ensure data integrity.
    - The storage quota for both `localStorage` and `sessionStorage` is 10MB per process.

Note

  • The --localstorage-file option is currently documented but not implemented in the Node.js core. Therefore, the added documentation is primarily for reference and future-proofing.
  • No new tests have been included, as this PR only addresses documentation changes.
  • I feel that my contributions are still lacking, and I appreciate any feedback you may have to help me improve. Thank you for your understanding.

Please review the documentation updates, and let me know if there are any additional changes or clarifications needed.

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Aug 30, 2024
Comment on lines +1202 to +1214
## Web Storage API

In Node.js, the localStorage and sessionStorage objects function differently compared to browsers or Deno:

* Both `localStorage` and `sessionStorage` are scoped to the current process,
not individual users or server requests. This is crucial for applications
like server-side rendering.
* `localStorage` uses the value of the `--localstorage-file` flag as its
origin. This file can be accessed simultaneously by multiple processes,
which may require implementing file locking or other synchronization
mechanisms to ensure data integrity.
* The storage quota for both `localStorage` and `sessionStorage` is
10MB per process.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this information is already present in this file under localStorage and sessionStorage

@@ -3385,6 +3385,15 @@ for MiB in 16 32 64 128; do
done
```

### --localstorage-file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this entry already exists somewhere else in the file.

@RedYetiDev
Copy link
Member

Possible duplicate of #53881

@RedYetiDev RedYetiDev closed this Oct 15, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants