Skip to content

localStorage's behaviour when no or invalid --localstorage-file provided #60303

@Renegade334

Description

@Renegade334

Prior to #57666, accessing the global localStorage would throw an error if --localstorage-file was invalid at the point of lazy initialisation.

Now, it provides an empty proxy object which responds undefined to all property access. This is neither spec-compliant nor straightforwardly observable.

Looking at the PR, it seems like this was an attempt to avoid throwing warnings in the test suite if simply testing for the presence of the global variable. It seems to me like the better approach would be for the tests to be changed (eg. by checking for the flag instead), and for the implementation to be kept sane.

A couple of options would be:

  • Implement mcollina's original proposal, and have the getter warn and return undefined if the storage cannot be initialised.
  • The localStorage global getter is allowed to throw a DOMException in the spec if the storage cannot be safely initialised, which is more abrupt, but arguably more consistent with the web.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions