AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
142.14k stars 26.84k forks source link

[Bug]: /v1/progress crashes with NaN. Please Fix. #13225

Open gravitate-dev opened 1 year ago

gravitate-dev commented 1 year ago

Is there an existing issue for this?

What happened?

*** API error: GET: http://127.0.0.1:7860/sdapi/v1/progress {'error': 'TypeError', 'detail': '', 'body': '', 'errors': "unsupported operand type(s) for -: 'float' and 'NoneType'"} Traceback (most recent call last): File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 98, in receive return self.receive_nowait() ^^^^^^^^^^^^^^^^^^^^^ File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 93, in receive_nowait raise WouldBlock anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 78, in call_next
    message = await recv_stream.receive()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 118, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\stable-diffusion\modules\api\api.py", line 187, in exception_handling
    return await call_next(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
    raise app_exc
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 108, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\modules\api\api.py", line 151, in log_and_time
    res: Response = await call_next(req)
                    ^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
    raise app_exc
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
    await self.app(scope, receive, send)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 24, in __call__
    await responder(scope, receive, send)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 44, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
    raise exc
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
    raise e
  File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 237, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 165, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\stable-diffusion\modules\api\api.py", line 505, in progressapi
    time_since_start = time.time() - shared.state.time_start
                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

Steps to reproduce the problem

  1. Call /progress

What should have happened?

Shouldnt crash. Crashes the whole a1111

Sysinfo

latest.

What browsers do you use to access the UI ?

No response

Console logs

*** API error: GET: http://127.0.0.1:7860/sdapi/v1/progress {'error': 'TypeError', 'detail': '', 'body': '', 'errors': "unsupported operand type(s) for -: 'float' and 'NoneType'"}
    Traceback (most recent call last):
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 98, in receive
        return self.receive_nowait()
               ^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 93, in receive_nowait
        raise WouldBlock
    anyio.WouldBlock

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 78, in call_next
        message = await recv_stream.receive()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 118, in receive
        raise EndOfStream
    anyio.EndOfStream

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\stable-diffusion\modules\api\api.py", line 187, in exception_handling
        return await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 108, in __call__
        response = await self.dispatch_func(request, call_next)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\modules\api\api.py", line 151, in log_and_time
        res: Response = await call_next(req)
                        ^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 24, in __call__
        await responder(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 44, in __call__
        await self.app(scope, receive, self.send_with_gzip)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
        raise exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
        raise e
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 718, in __call__
        await route.handle(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 66, in app
        response = await func(request)
                   ^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 237, in app
        raw_response = await run_endpoint_function(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 165, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
        return await future
               ^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
        result = context.run(func, *args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\modules\api\api.py", line 505, in progressapi
        time_since_start = time.time() - shared.state.time_start
                           ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
    TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

Additional information

No response

gravitate-dev commented 1 year ago

Its not nice to crash a1111. Perhaps setting 0 here would be better than crashing a1111 time_start = shared.state.time_start if shared.state.time_start is not None else 0 time_since_start = time.time() - time_start

w-e-w commented 1 year ago

yes I found under an extreme condition extreme situation that it is possible for shared.state.time_start to be None which triggers an exception that you're describing but I don't see it crash the entire server also by the fact that you are receiving that reply message ment the server has not crashed perhaps you're using the word crash incorrectly