Skip to content

fix: clear execution references when engine run finishes#1443

Open
saschabuehrle wants to merge 1 commit intoinngest:mainfrom
saschabuehrle:fix/issue-1440-clear-v1-execution-state
Open

fix: clear execution references when engine run finishes#1443
saschabuehrle wants to merge 1 commit intoinngest:mainfrom
saschabuehrle:fix/issue-1440-clear-v1-execution-state

Conversation

@saschabuehrle
Copy link
Copy Markdown

@saschabuehrle saschabuehrle commented Apr 5, 2026

Fixes #1440

The execution engine retained internal references after completion (steps map, metadata, step state, fnArg, and the execution promise). In long-running processes this can keep step closures and large payloads reachable longer than necessary.

This adds a cleanup pass in the _start finally block to release those references once a run is finished, and includes a regression test that asserts the state is cleared after completion.

Greetings, saschabuehrle


Note

Adds a releaseExecutionReferences() cleanup method called in the finally block of _start() to clear step maps, metadata, step state, fnArg, and the execution promise after a run finishes. Includes a regression test that casts to internal types to assert the cleared state.

Written by Mendral for commit 17ecdc2.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 5, 2026

⚠️ No Changeset found

Latest commit: 17ecdc2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown

@mendral-app mendral-app Bot left a comment

Choose a reason for hiding this comment

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

LGTM

The cleanup is safe: it runs in the finally block after the core loop has fully resolved or errored, no external caller holds a reference to the execution object after start() completes, and all middleware hooks fire before the finally block. No correctness, data-loss, or security issues found.

Tag @mendral-app with feedback or questions. View session

@fdarian
Copy link
Copy Markdown

fdarian commented Apr 6, 2026

It hasn't fixed the leak in my test, feel free to run against https://github.com/fdarian/inngest-memory-leak-repro


CleanShot 2026-04-06 at 19 35 16

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.

[BUG] V1 Execution state is never cleared after completion, causing memory leak

2 participants