Skip to content

2.0.0-beta.14: Null-prototype store crashes when reading a function-valued property #2771

Description

@yumemi-thomas

Describe the bug

In Solid 2.0.0-beta.14, creating a store from a null-prototype object can crash when reading a function-valued property.

Null-prototype objects are commonly used as dictionary objects because they avoid inherited keys like constructor and __proto__. A store proxy should be able to wrap and read them.

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-fv9dqmqx?file=src%2FApp.tsx

import { createSignal, createStore } from 'solid-js';

const dictionary: any = Object.create(null);
dictionary.getValue = () => 42;

export default function App() {
  const [store] = createStore(dictionary);
  const [result, setResult] = createSignal('not run');

  return (
    <main>
      <button
        onClick={() => {
          try {
            setResult(`value: ${store.getValue()}`);
          } catch (error) {
            setResult(String(error));
          }
        }}
      >
        call function property
      </button>

      <p>{result()}</p>
    </main>
  );
}

Steps to Reproduce the Bug or Issue

  1. Open the repro.
  2. Click call function property.
  3. Observe the rendered result.

Expected behavior

The function-valued property should be read and callable:

value: 42

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: current stable

Additional context

This appears related to packages/solid-signals/src/store/store.ts, where a function-valued property read calls .hasOwnProperty directly on the wrapped source object. Null-prototype objects do not inherit hasOwnProperty, so the check should use a safe form such as Object.prototype.hasOwnProperty.call(...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions