Skip to content

Restarting comfyui crashes stability matrix #1342

Description

@phazei

What happened?

it doesn't happen everytime, but quite often now. and when it happens, it seems disconnected from python. I need to open task manager and end task python or I can't start comfyui again. This started since the last update.

Steps to reproduce

No response

Relevant logs

Version

2.143

What Operating System are you using?

Windows

Activity

  1. mcDandy commented on Jul 26, 2025

    @mcDandy

    Got the same problem so adding log

    Exception

    Win32Exception: Přístup byl odepřen.

    Sentry ID

    5dd22178

    Stack Trace

       at StabilityMatrix.Core.Helper.ProcessTracker.AddProcess(Process process)
       at StabilityMatrix.Core.Processes.ProcessRunner.StartTrackedProcess(Process process)
       at StabilityMatrix.Core.Processes.ProcessRunner.StartAnsiProcess(String fileName, String arguments, String workingDirectory, Action`1 outputDataReceived, IReadOnlyDictionary`2 environmentVariables)
       at StabilityMatrix.Core.Python.PyVenvRunner.RunDetached(ProcessArgs args, Action`1 outputDataReceived, Action`1 onExit, Boolean unbuffered)
       at StabilityMatrix.Core.Models.Packages.ComfyUI.RunPackage(String installLocation, InstalledPackage installedPackage, RunPackageOptions options, Action`1 onConsoleOutput, CancellationToken cancellationToken)
       at StabilityMatrix.Avalonia.Services.RunningPackageService.StartPackage(InstalledPackage installedPackage, String command, CancellationToken cancellationToken)
       at StabilityMatrix.Avalonia.ViewModels.PackageManager.PackageCardViewModel.Launch()
       at AsyncAwaitBestPractices.SafeFireAndForgetExtensions.HandleSafeFireAndForget[TException](Task task, Boolean continueOnCapturedContext, Action`1 onException)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.OnOSTimer()
       at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
       at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
       at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    
  2. phazei commented on Jul 26, 2025

    @phazei
    Author

    Exception

    Win32Exception: Access is denied.

    Sentry ID

    317081b6

    Stack Trace

       at StabilityMatrix.Core.Helper.ProcessTracker.AddProcess(Process process)
       at StabilityMatrix.Core.Processes.ProcessRunner.StartTrackedProcess(Process process)
       at StabilityMatrix.Core.Processes.ProcessRunner.StartAnsiProcess(String fileName, String arguments, String workingDirectory, Action`1 outputDataReceived, IReadOnlyDictionary`2 environmentVariables)
       at StabilityMatrix.Core.Python.PyVenvRunner.RunDetached(ProcessArgs args, Action`1 outputDataReceived, Action`1 onExit, Boolean unbuffered)
       at StabilityMatrix.Core.Models.Packages.ComfyUI.RunPackage(String installLocation, InstalledPackage installedPackage, RunPackageOptions options, Action`1 onConsoleOutput, CancellationToken cancellationToken)
       at StabilityMatrix.Avalonia.Services.RunningPackageService.StartPackage(InstalledPackage installedPackage, String command, CancellationToken cancellationToken)
       at StabilityMatrix.Avalonia.ViewModels.PackageManager.PackageCardViewModel.Launch()
       at AsyncAwaitBestPractices.SafeFireAndForgetExtensions.HandleSafeFireAndForget[TException](Task task, Boolean continueOnCapturedContext, Action`1 onException)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.Signaled()
       at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
       at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
       at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    
  3. drdancm commented on Jul 26, 2025

    @drdancm

    stabilitymatrix-log-2025-07-26-18-22-20.zip

    Same problem StabMatrix crashed during CompfyUI update, and now it won't even start. Error message:

    Exception

    JsonException: Expected depth to be zero at the end of the JSON payload. There is an open JSON object or array that should be closed. Path: $ | LineNumber: 306 | BytePositionInLine: 0.
    JsonReaderException: Expected depth to be zero at the end of the JSON payload. There is an open JSON object or array that should be closed. LineNumber: 306 | BytePositionInLine: 0.

    Sentry ID

    159d1006

    Stack Trace

       at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
       at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, T& value)
       at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Stream utf8Json)
       at StabilityMatrix.Core.Services.SettingsManager.LoadSettings(CancellationToken cancellationToken)
       at StabilityMatrix.Core.Services.SettingsManager.TryFindLibrary(Boolean forceReload)
       at StabilityMatrix.Avalonia.App.ConfigureServiceProvider()
       at StabilityMatrix.Avalonia.App.OnFrameworkInitializationCompleted()
       at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    ```   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
       at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
       at System.Text.Json.Utf8JsonReader.Read()
       at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
       at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
       at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)```
    
  4. drdancm commented on Jul 28, 2025

    @drdancm

    StabMatrix will not run at this point. Should I reload the latest version? Is that likely to allow it to start?


    many days later:
    That will not help. Get an Ai like Gemini to look at the error messages and tell you how to fix it.

  5. hansnolte commented on Aug 26, 2025

    @hansnolte

    Is there now a solution or a workaround for this problem?

  6. drdancm commented on Aug 26, 2025

    @drdancm

    I got Gemini Ai to help me fix the problem. It was simply a matter of fixing the startup json because it was missing a }
    I highly recommend getting help from an Ai, which has helped me solve lots of issues with Apps not working properly.

  7. hansnolte commented on Aug 26, 2025

    @hansnolte

    Hi drdancm,

    thank you for the hint!
    I will give it a try.

    Bye
    Hans

  8. phazei commented on Aug 26, 2025

    @phazei
    Author

    @drdancm where were you missing the "}"?

    System.Text.Json.JsonException: '}' is invalid after a single JSON value. Expected end of data. Path: $ | LineNumber: 0 | BytePositionInLine: 851.
    This indicates a corrupted JSON file: D:\AITools\StabilityMatrixData\.downloads\a77f0185-139c-4fa5-b896-220dd9ad63a8.json. This file likely tracks your in-progress downloads. While not the direct cause of the restart failure, it's an underlying issue that could cause problems with future downloads or update checks.
    
    

    For anyone in the future, this could be it. Just delete whatever's in your .downloads

    EDIT: that doesn't actually fix anything, it was some other bug. Really it's an internal app error, so generally asking AI for help with that isn't going to do much good unless you want to load up the open source code and debug it yourself.

  9. hansnolte commented on Aug 27, 2025

    @hansnolte

    For anyone in the future, this could be it. Just delete whatever's in your .downloads

    Doesn't work for me.
    My .downloads Folder is Empty and StabilityMatrix still crashes if I want to close it.

  10. drdancm commented on Aug 27, 2025

    @drdancm

    The idea is to have an Chatbot look over your particular error message and tell you what is causing the problem, and tell you how to fix it. The specific example I gave was just my vague memory of what it took to fix things. I did not keep a record so I don't remember the exact details.

    I recommend using Ai to help with any of these issues, because, although there is no guarantee, you have their undivided attention and their superb attention to detail. My experience is that Gemini, for example helped me to get Apps to run which totally failed at first, after spending a couple of hours to fix every new dependency as we progressed to eliminate all of the problems.

  11. phazei commented on Aug 31, 2025

    @phazei
    Author

    Ok, so, I have a little more clarity on the issue that should help out a little bit.

    It seems when ComfyUI restarts itself, the process is no longer a child of StabilityMatrix. So StabilityMatrix attempts to claim ownership of it, with no fail check. and for one reason or another, it fails, and crashes. That would be fine and dandy if we just don't restart inside of ComfyUI, but it doesn't stop there.

    Even if you don't restart in ComfyUI, when StabilityMatrix restarts itself, it tries to shut itself down. and then sees the instance that hasn't shut down yet, and tries to take ownership of it, and fails and crashes. So, to avoid it crashing. you have to click stop, then wait, I have my task manager open and filtering "python". Once the python process disappears, then you can click start again and SM won't crash. If the py process never goes away. then end-tasking it first then hitting start in SM also works.

    I really hope they fix it, it was better when it just lost the stupid connection.

  12. mcDandy commented on Aug 31, 2025

    @mcDandy
  13. github-actions commented on Oct 31, 2025

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove the stale label or comment, else this will be closed in 7 days.

  14. added
    staleStale issue or inactive for long period of time
    on Oct 31, 2025
  15. phazei commented on Oct 31, 2025

    @phazei
    Author

    This was fixed a version ago

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

    bugSomething isn't workingstaleStale issue or inactive for long period of time

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions