Skip to content

Dispose the current step in Plugin.Stop#11

Merged
redstrate merged 1 commit into
redstrate:mainfrom
jblemee:fix/dispose-current-step-on-stop
May 1, 2026
Merged

Dispose the current step in Plugin.Stop#11
redstrate merged 1 commit into
redstrate:mainfrom
jblemee:fix/dispose-current-step-on-stop

Conversation

@jblemee

@jblemee jblemee commented May 1, 2026

Copy link
Copy Markdown
Contributor

Problem

When the user clicks Close on the End step, Plugin.Stop() sets CurrentStep to null without calling Dispose() on it first:

public void Stop()
{
    CurrentStep = null;
    StepWindow.IsOpen = false;
    package = null;
}

EndStep owns an EmbedIO WebServer bound to http://localhost:42073/ — started in Run, torn down in Dispose. With Stop bypassing Dispose, the server keeps listening on 42073 for the rest of the game session and the step's resources leak. The same shape of leak applies to any other step that subscribes to events in its constructor: PlaytimeStep for instance hooks ChatGui.ChatMessage in .ctor and unhooks it in Dispose.

I noticed this while clicking Close after the export finished — the window dismissed, but ss -tlnp still showed the EmbedIO listener attached to ffxiv_dx11.exe.

Change

Call CurrentStep?.Dispose() before nulling the field. One-line change.

NextStep() already disposes the step on the natural end-of-pipeline path (_stepIndex >= _steps.Count), so this just makes the Stop() codepath behave consistently.

Testing

After the change, clicking Close on the End step shuts the EmbedIO listener down (verified — port 42073 no longer in ss -tlnp output). No behavioral change to the success path.

When the user clicks "Close" on the End step, Plugin.Stop() sets
CurrentStep to null without calling Dispose on it first. EndStep owns
an EmbedIO WebServer bound to localhost:42073 (started in Run, torn
down in Dispose), so the server keeps listening on the port for the
rest of the game session and the step's resources leak. Other steps
that subscribe to events in their constructor (e.g. PlaytimeStep,
which hooks ChatGui.ChatMessage) leak in the same way if Stop is
called before they complete naturally.

Call CurrentStep?.Dispose() before nulling the field so the step
releases what it owns.
@redstrate redstrate merged commit ccc6111 into redstrate:main May 1, 2026
1 check failed
@jblemee jblemee deleted the fix/dispose-current-step-on-stop branch May 1, 2026 20:56
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.

2 participants