- Reference
- Script API
Limits
Every script run has a budget. A script that spends its instructions or its wall clock is stopped, and the run fails with timeout.
| Limit | Default | Applies to | Configurable |
|---|---|---|---|
| Instructions | 1,000,000 per run | Queries, procedures, record and label scripts | Yes, 1,000 to 1,000,000,000 |
| Wall clock | 10 seconds per run | Queries, procedures, record and label scripts | Yes, 1 to 300 seconds |
| Memory | 64 MiB per run | Every script type, jobs included | No |
| Stack (JavaScript and TypeScript) | 384 KiB | Every script type | No |
Jobs have no instruction limit and no wall clock, because running long is what a job is for. A job should check ctx.job.should_stop() and return when it is asked to stop.
Instructions
Section titled “Instructions”The instruction limit stops runaway loops. What counts as one instruction depends on the language’s engine, so the same setting allows a different amount of work in each language.
A run can’t recover from a spent budget. pcall and try/catch don’t stop it, and the run fails with timeout.
Wall clock
Section titled “Wall clock”A run that hits the wall clock fails with timeout. In a JavaScript or TypeScript script, library calls still in flight when the run is cut short are dropped with it.
Memory
Section titled “Memory”Each run may allocate up to 64 MiB. Running out is a normal script error with errorType memory. The host also holds the interpreter to twice that amount.
In JavaScript and TypeScript, runaway recursion throws RangeError: Maximum call stack size exceeded, which a script can catch.
What a client sees
Section titled “What a client sees”For a query or procedure:
| Cause | errorType | Status |
|---|---|---|
| Instruction limit or wall clock | timeout | 408 |
| Memory | memory | 500 |
For a record or label script, the failure is retried and then dead-lettered. For a job, the job fails. See failures and retries.
Change the limits
Section titled “Change the limits”Set the instruction limit and wall clock in the dashboard under System > General, in the Instruction limit and Request wall clock (seconds) fields. You can also set them with environment variables:
SCRIPT_INSTRUCTION_LIMIT=5000000SCRIPT_WALL_CLOCK_SECONDS=30Each value is read from the dashboard setting first, then the environment variable, then the default. A value outside the allowed range is refused when you save it in the dashboard. An environment value outside the range is logged as a warning and the default is used. A change reaches other instances that share the database within 10 seconds.
Other caps
Section titled “Other caps”- A
ctx.job.wait(seconds)call is clamped to between 0 and 3600 seconds. - A record query through
happyview.dbreturns 20 records by default and at most 100 per page. Paginate with the cursor for more. - A script description can be up to 300 characters.
- A test file run by
happyview testmay spend up to 60 seconds of its own time, outside the triggers it fires.
Next steps
Section titled “Next steps”© HappyProto

