Skip to content

How Run duration is counted

Understand elapsed time, direct Database operations, and retries.

Applies to
CLIConsoleAPI

Verified · v1.4.24

Markdown

Your daily time allowance resets at midnight UTC. Free accounts get 30 minutes; AGI Lab members get 6 hours. New Free accounts get 10 minutes during their first 7 days. Wings counts elapsed time from start to finish. New code runs also have a separate count limit across the last 7 UTC days.

New code runs

New code runs include every ad hoc code attempt (wings run --code, --file, or stdin) and the first run of a new or changed Handler version. The allowance is 300 for Free, including new Free accounts, and 3,000 for members across today and the previous 6 UTC days. Code, normalized connection bindings and the database binding define a version; changing A to B and back to A or deleting and recreating a Handler counts again. Ordinary reruns of the last version counted for that Handler do not count, even on another day or after a platform runtime update. If a schedule retry creates a replacement Worker, that retry counts once, even for the same version. It counts even if a Wings-side failure prevents your code from starting. At the limit, it stops before creating that Worker. This applies to CLI, Schedules, API Triggers, Web Apps and calls from another Handler. At new_code_run_limit_exceeded, check the count and limit with wings usage. resetAt is when the oldest counted day leaves the total; usage may still be at or above the limit afterward. Runs of a new or changed version and retries that create a fresh Worker remain blocked until usage falls below the limit. You can run the last version counted for that Handler normally without consuming another new code run. Other limits still apply.

Accepted attempts still count if Worker preparation or execution fails; rejected admissions do not count. The API returns HTTP 429 with current, limit, resetAt and retryAfterSeconds. Check the new code runs (7 UTC days) row in wings usage (quota.newCodeRuns7Days in JSON).

Run time

Both successful and failed Runs count toward the daily allowance. Calling another Handler also uses time for the child Run. A timed-out Run counts up to its deadline.

A Run ends at the earlier of the plan's time limit and the remaining daily allowance. Scheduled and manual attempts do not count if Wings fails before calling the execution environment. After that call, elapsed time counts even if the Handler's code never starts.

Database time

Database work outside a Run also counts toward the daily allowance. This includes wings db query, wings db exec, and browsing tables in the Console.

An env.db call is already part of its Run's elapsed time. It is not counted twice. There is no separate daily Database time allowance.

When the daily allowance runs out

New Runs and Database operations outside Runs cannot start. They return rate_limited (HTTP 429, scope: duration_day). retryAfterSeconds tells you how many seconds remain until midnight UTC. Time reserved for active Runs also reduces the available allowance. Database calls inside an active Run are not stopped for this reason.

A Schedule retries at midnight only if midnight comes before its next occurrence. Otherwise, that occurrence is skipped with superseded_by_next_occurrence and creates no Run. An already scheduled retry also skips if a newer occurrence has been created. See Schedules.

Waiting for a Database

An account runs one Database operation at a time. If an operation outside a Run waits but never starts, that waiting time is not added as Database usage. Waiting for a Database inside a Run still counts toward that Run’s elapsed time. The Database operation's time is not counted twice.

An operation outside a Run waits up to 9.5 seconds. Inside a Run, it can wait until 0.5 seconds before the Run's deadline.

Temporary Database pauses

An operation taking more than 5 seconds on Free or 10 seconds for members pauses Database operations for 15 minutes. A second pause on a Free account in the same UTC day lasts until midnight.

If the outcome of an operation is unknown, Wings counts 30 seconds. It adjusts that value when the measured time becomes available. Only operations outside a Run add those 30 seconds to the daily allowance. Inside a Run, the Run's own elapsed time is counted. A lost response can leave the next operation waiting for up to 5 minutes.

When Wings finishes an operation with its outcome marked unknown, Database operations are also paused. If a started operation reaches its 5-minute deadline without a result, that alone does not pause Database operations.

If you receive db_time_quota_exceeded, check reason and retryAfterSeconds. busy means an earlier operation has not finished; paused means a temporary pause is in effect. Wait for the indicated time before trying again.