# wait()

Canonical URL: https://developers.iagenify.com/ar/sdk/ref/workflow-run/wait/
Language: ar

`run.wait({ until?, timeoutMs?, intervalMs? }) → Promise<WorkflowRun>`

( ١ تيموثاوس ٣ : ١ ) لكنَّ هذه الخدعة لا تزال تُعرض على الناس حتى يصلوا الى احدى الحالات التي ذكرتها .

Status: 10 minutes · every 2 seconds · waiting counts as arrived

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `until` | string[] | ["waiting", "succeeded", "failed", "cancelled"] | و التي تنتهي حالة الانتظار |
| `timeoutMs` | integer | 600 000 | عشر دقائق، مررها `timeout` (4008) تم إلقائها. |
| `intervalMs` | integer | 2 000 | كم مرة تعيد قراءة هذا |

```javascript
await run.wait();

if (run.data.status === "waiting") {
  const step = run.data.steps.find((s) => s.status === "waiting");
  await run.resume(step.id, { approved: true });
  await run.wait();                       // then on to the end
}
```

## لماذا الانتظار في حالة العجز {#waiting}

> **خطوة بشرية تنتظر الى أجل**
>
> وبدون الانتظار في القائمة، تنتهي الانتظار الافتراضي دائماً في فترة زمنية محددة على أي تدفق للعمل مع موافقة - وسيبدو الوقت المستغرق كفشل. فعاملة "التوقف بالنسبة لشخص" باعتباره وصولاً هو ما يجعل التقصير مفيداً.

## ينتظر فقط النهاية {#terminal}

```javascript
await run.wait({ until: ["succeeded", "failed", "cancelled"], timeoutMs: 30 * 60_000 });
```

( ١ بطرس ٣ : ١ ) فَٱلْمَسِيحِيُّونَ ٱلْمُقَدَّسُونَ يَسْتَخْدِمُونَ ٱلْمَسِيحِيُّونَ ٱلْمُقَدَّسُونَ مَعَ ٱلْمَسِيحِيِّينَ .

## الوقت المنقضي لا يوقف الركض {#timeout}

هو يُلقي `timeout` و الركض يستمر بالسير، أمسكه و عد لاحقاً مع [أنتRunRun](/ar/sdk/ref/workflows/get-run) أو - أو - أو [إلغاء ()](/ar/sdk/ref/workflow-run/cancel) إذا كنت تنوي إيقافه

```javascript
import { IaGenifyError } from "iagenify";

try {
  await run.wait({ timeoutMs: 60_000 });
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "timeout") {
    // Still running. Keep run.id and come back.
  } else throw err;
}
```

## الـ هو حرّ، لكن ليس conf {#polling-cost}

كل علامة هي قراءة وقراءة تكلفة لا شيء، وفترة أقصر تتفاعل بسرعة أكبر وتقدم طلبات أكثر - ثانيتان هو التوازن المختار.

- [resume()](/ar/sdk/ref/workflow-run/resume): ما عادة ما يلي.
- [(الحلقة الرابعة)](/ar/sdk/workflows/steps/human): الخطوة التي تجعل من الانتظار الركض.

```python
run.wait()

if run.data["status"] == "waiting":
    step = next(s for s in run.data["steps"] if s["status"] == "waiting")
    run.resume(step["id"], {"approved": True})
    run.wait()                       # then on to the end
```

```python
run.wait(until=["succeeded", "failed", "cancelled"], timeout_ms=30 * 60_000)
```

```python
from iagenify import IaGenifyError

try:
    run.wait(timeout_ms=60_000)
except IaGenifyError as error:
    if error.code != "timeout":
        raise
    # Still running. Keep run.id and come back.
```
