Skip to content

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.

LimitDefaultApplies toConfigurable
Instructions1,000,000 per runQueries, procedures, record and label scriptsYes, 1,000 to 1,000,000,000
Wall clock10 seconds per runQueries, procedures, record and label scriptsYes, 1 to 300 seconds
Memory64 MiB per runEvery script type, jobs includedNo
Stack (JavaScript and TypeScript)384 KiBEvery script typeNo

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.

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.

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.

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.

For a query or procedure:

CauseerrorTypeStatus
Instruction limit or wall clocktimeout408
Memorymemory500

For a record or label script, the failure is retried and then dead-lettered. For a job, the job fails. See failures and retries.

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:

Terminal window
SCRIPT_INSTRUCTION_LIMIT=5000000
SCRIPT_WALL_CLOCK_SECONDS=30

Each 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.

  • A ctx.job.wait(seconds) call is clamped to between 0 and 3600 seconds.
  • A record query through happyview.db returns 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 test may spend up to 60 seconds of its own time, outside the triggers it fires.