BennyKok / comfyui-deploy

An open source `vercel` like deployment platform for Comfy UI
https://comfydeploy.ing
GNU Affero General Public License v3.0
983 stars 126 forks source link

fix: update next version and routing parameter errors #55

Closed ihmily closed 2 months ago

ihmily commented 2 months ago

fix https://github.com/BennyKok/comfyui-deploy/issues/32#issue-2165996900 when update the next version to 14.2 , it works !

fix https://github.com/BennyKok/comfyui-deploy/issues/43 and the following errors

Error: Error creating run, Internal Server Error
    at $$ACTION_0 (webpack-internal:///(action-browser)/./src/server/createRun.ts:164:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async E:\comfyui-deploy\web\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:39:418
    at async rw (E:\comfyui-deploy\web\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:38:7978)
    at async r6 (E:\comfyui-deploy\web\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:41:1256)
    at async doRender (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:1438:30)
    at async cacheEntry.responseCache.get.routeKind (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:1587:40)
    at async DevServer.renderToResponseWithComponentsImpl (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:1507:28)
    at async DevServer.renderPageComponent (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:1931:24)
    at async DevServer.renderToResponseImpl (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:1969:32)
    at async DevServer.pipeImpl (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:920:25)
    at async NextNodeServer.handleCatchallRenderRequest (E:\comfyui-deploy\web\node_modules\next\dist\server\next-server.js:272:17)
    at async DevServer.handleRequestImpl (E:\comfyui-deploy\web\node_modules\next\dist\server\base-server.js:816:17)
    at async E:\comfyui-deploy\web\node_modules\next\dist\server\dev\next-dev-server.js:339:20
    at async Span.traceAsyncFn (E:\comfyui-deploy\web\node_modules\next\dist\trace\trace.js:154:20)
    at async DevServer.handleRequest (E:\comfyui-deploy\web\node_modules\next\dist\server\dev\next-dev-server.js:336:24)
    at async invokeRender (E:\comfyui-deploy\web\node_modules\next\dist\server\lib\router-server.js:174:21)
    at async handleRequest (E:\comfyui-deploy\web\node_modules\next\dist\server\lib\router-server.js:353:24)
    at async requestHandlerImpl (E:\comfyui-deploy\web\node_modules\next\dist\server\lib\router-server.js:377:13)
    at async Server.requestListener (E:\comfyui-deploy\web\node_modules\next\dist\server\lib\start-server.js:141:13)
 POST /workflows/95bdb64c-e6c0-4a36-bb67-63a22087b9a9 200 in 1975ms

Reason

/comfyui-deploy/web/src/server/createRun.ts

 const shareData = {
      workflow_api: workflow_api,
      status_endpoint: `${origin}/api/update-run`,
      file_upload_endpoint: `${origin}/api/file-upload`,
    };
 case "classic":
          const body = {
            ...shareData,
            prompt_id: prompt_id,
          };
          // console.log(body);
          const comfyui_endpoint = `${machine.endpoint}/comfyui-deploy/run`;
          const _result = await fetch(comfyui_endpoint, {
            method: "POST",
            body: JSON.stringify(body),
            cache: "no-store",
          });

above use workflow_api as request parameters but the router handle use worlflow_api_raw /comfyui-deploy/custom_routes.py

@server.PromptServer.instance.routes.post("/comfyui-deploy/run")
async def comfy_deploy_run(request):
    data = await request.json()

    # In older version, we use workflow_api, but this has inputs already swapped in nextjs frontend, which is tricky
    workflow_api = data.get("workflow_api_raw")
    # The prompt id generated from comfy deploy, can be None
    prompt_id = data.get("prompt_id")
    inputs = data.get("inputs")
BennyKok commented 2 months ago

Hey! Appreciate for the fix!