Skip to content

[Bug] createShortCache bypasses cache when value is falsy (false, 0, "") #1160

Description

@MeiSiristhebest

🙋 SDK Version

Latest main (@flowgram.ai/utils)

📌 Layout

All layouts (Core Utility / Reactive Cache)

💻 Environment

  • Operation System: All (Cross-platform)
  • Node.js: 18 / 20 LTS

📝 Description

In @flowgram.ai/utils (packages/common/utils/src/cache.ts), createShortCache uses if (cache) to determine cache validity:

if (cache) {
  updateTimeout();
  return cache;
}

When a cached value is falsy (e.g. false, 0, "", null), if (cache) evaluates to false, causing the cache to be bypassed on every subsequent get() invocation and executing the compute function repeatedly.

In addition, ShortCache lacks a dispose() / clear() method to clean up active setTimeout timers on teardown.

I have a verified minimal fix with regression tests ready to submit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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