Skip to content

improvement(redis-cleanup): schedule, async workflow, hitl base64 cache cleanup#4646

Merged
icecrasher321 merged 2 commits into
stagingfrom
improvement/redis-cleanup
May 17, 2026
Merged

improvement(redis-cleanup): schedule, async workflow, hitl base64 cache cleanup#4646
icecrasher321 merged 2 commits into
stagingfrom
improvement/redis-cleanup

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Base64 cache cleanup on schedule, async workflow, hitl resume on execution end instead of waiting for ttl

Type of Change

  • Other: Code cleanup

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 17, 2026 10:00pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 17, 2026

PR Summary

Low Risk
Low risk: adds best-effort finally cleanup calls after execution completion; behavior changes are limited to Redis cache eviction and should not affect core execution results.

Overview
Base64 cache entries are now cleaned up at execution end instead of waiting for TTL.

Scheduled executions (schedule-execution), background workflow executions (workflow-execution), and HITL resume runs now call cleanupExecutionBase64Cache(executionId) in finally blocks to best-effort evict per-execution user-file base64 cache/budget keys.

Reviewed by Cursor Bugbot for commit 3a4d277. Configure here.

@icecrasher321 icecrasher321 changed the base branch from main to staging May 17, 2026 20:07
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR eagerly cleans up Redis-backed base64 file caches at workflow execution end rather than waiting for TTL expiry. The cleanup is added via finally blocks in the schedule and async workflow execution paths, and inline in the HITL resume path.

  • schedule-execution.ts / workflow-execution.ts: A finally clause wrapping the existing try/catch block calls cleanupExecutionBase64Cache with void, ensuring cache teardown on both success and error paths without blocking the execution return.
  • human-in-the-loop-manager.ts: cleanupExecutionBase64Cache(resumeExecutionId) is placed at the end of the existing finally block so each resume segment's cached data is freed immediately after the resume execution completes (including re-pause and error cases).

Confidence Score: 5/5

Safe to merge — the changes only add eager Redis cache cleanup, and the underlying function already absorbs all errors internally.

All three call sites correctly scope the cleanup to the execution ID used when populating the cache. The cleanupExecutionBase64Cache function has its own internal try/catch so void firing it without awaiting is safe. The finally placement ensures cleanup runs even on early-return error paths, and in the HITL path the cleanup covers every outcome including re-pause — in that case files are simply re-fetched from durable storage on the next resume.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/background/schedule-execution.ts Adds a finally block that calls cleanupExecutionBase64Cache(executionId) with void; executionId is a named parameter to runWorkflowExecution, so it is always in scope and the cleanup correctly fires on both success and error paths.
apps/sim/background/workflow-execution.ts Adds a finally block that calls cleanupExecutionBase64Cache(executionId) with void; executionId is set from correlation.executionId before the try block, so it is always in scope.
apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts Appends cleanupExecutionBase64Cache(resumeExecutionId) at the end of the existing finally block so each resume segment's cache is cleaned up immediately, including re-pause and error outcomes.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Executor as Workflow/Schedule/HITL Executor
    participant Redis as Redis (base64 cache)
    participant Storage as File Storage

    Caller->>Executor: start execution
    Executor->>Storage: read user files
    Executor->>Redis: cache base64 (SET_BASE64_CACHE_SCRIPT)
    note over Executor: workflow runs...

    alt success / error
        Executor-->>Caller: return result / throw
    else re-pause (HITL)
        Executor-->>Caller: paused event written
    end

    note over Executor: finally block
    Executor->>Redis: cleanupExecutionBase64Cache(executionId)
    Redis-->>Executor: cache entries deleted (CLEANUP_BASE64_CACHE_ENTRY_SCRIPT)
    note over Executor: budget counters decremented
Loading

Reviews (2): Last reviewed commit: "address comments" | Re-trigger Greptile

Comment thread apps/sim/background/workflow-execution.ts Outdated
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3a4d277. Configure here.

@icecrasher321 icecrasher321 merged commit 4dc78cb into staging May 17, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/redis-cleanup branch May 18, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant