Skip to content

doc: clarify Web Storage behavior

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.

Merge request reports

Loading