> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # Run.restart() `.restart()` 方法會重新啟動與伺服器失去連線的有效 Workflow run,讓你從失去連線的一刻(最後一個有效 step)繼續執行。 ## 使用範例 ```typescript const run = await workflow.createRun() const result = await run.start({ inputData: { value: 'initial data' } }) const restartedResult = await run.restart() ``` ## 參數 **requestContext** (`RequestContext`): 恢復執行時使用的 Request Context 資料 **tracingContext** (`TracingContext`): 用於建立 child span 及加入 metadata 的 Tracing context。使用 Mastra 的 tracing 系統時會自動注入。 **tracingContext.currentSpan** (`Span`): 用於建立 child span 及加入 metadata 的目前 span。可用它建立自訂 child span,或在執行期間更新 span 屬性。 **tracingOptions** (`TracingOptions`): Tracing 設定選項。 **tracingOptions.metadata** (`Record`): 要加入 root trace span 的 metadata。適合加入使用者 ID、session ID 或 feature flag 等自訂屬性。 **tracingOptions.requestContextKeys** (`string[]`): 要擷取並用作這個 trace 的 metadata 的其他 RequestContext key。巢狀值支援點號標記法(例如 'user.id')。 **tracingOptions.traceId** (`string`): 這次執行使用的 Trace ID(1 至 32 個十六進位字元)。如有提供,這個 trace 將成為指定 trace 的一部分。 **tracingOptions.parentSpanId** (`string`): 這次執行使用的 parent span ID(1 至 16 個十六進位字元)。如有提供,root span 將建立為此 span 的 child。 **tracingOptions.tags** (`string[]`): 要套用至這個 trace 的標籤。這些字串標籤用於分類及篩選 trace。 ## 傳回值 **result** (`Promise>`): 一個 Promise,其解析結果為包含 step 輸出及狀態的 Workflow 執行結果 **traceId** (`string`): 啟用 Tracing 時,與這次執行關聯的 Trace ID。可用於關聯 log 及偵錯執行流程。 **spanId** (`string`): 啟用 Tracing 時,與這次執行關聯的 root span ID。可用於 span 層級的查找及關聯。 ## 相關內容 - [Workflows 概覽](https://mastra.zisheng.pro/zh-HK/docs/workflows/overview) - [重新啟動 Workflow](https://mastra.zisheng.pro/zh-HK/docs/workflows/overview) - [Workflow.createRun()](https://mastra.zisheng.pro/zh-HK/reference/workflows/workflow-methods/create-run)