Skip to content

[Bug] Reusable VM allows context leak due to global symbol properties #1592

@mjameswh

Description

@mjameswh

Describe the bug

When the reuseV8Context option is enabled, the logic that swaps global variables in and out for a specific Workflow Execution only look at "regular" properties on globalThis, but ignores symbol properties. Symbol properties may therefore leak from one Workflow Execution to another.

In a recent investigation, this was identified as the cause of a memory leak when using Effect in Workflow Code, as Effect was storing its own "global store" as a symbol property on globalThis. Though this specific case has just been fixed on Effect's side, we recognize that there was nothing wrong in them using global symbol properties this way, and that other libraries are likely to do so. We must therefore ensure that Temporal SDK is able to properly handle global symbol properties.

Huge thanks to @izakfilmalter for his work in preparing a repro project for this issue, capturing heap dumps, and coordinating efforts between Effect's and Temporal's teams, as well as to @mikearnaldi from Effect for his precious collaboration in investigating this through.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions