Skip to content

_autoWrapCustomMethods may inadvertently execute getters when checking property type #432

@Flouse

Description

@Flouse

// Skip if it's a private method or not a function
if (
baseMethods.has(methodName) ||
methodName.startsWith("_") ||
typeof this[methodName as keyof this] !== "function"

When methodName refers to a getter, accessing this[methodName as keyof this] will execute the getter. This can lead to several undesirable outcomes that are contrary to the presumed intent of the method discovery process.

  1. Potential Side Effects**: If a getter tries to read this.state, it may throw Uncaught Error: no such table: cf_agents_state: SQLITE_ERROR Error, before the Agent is initialized.

  2. Performance Overhead: Executing getters, especially those with complex logic, during an iteration over all properties can introduce unnecessary computational overhead.
    may relate to: RPC error: RangeError: Maximum call stack size exceeded #430 (comment)

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