Every script runs in a sandbox with a fixed budget. Exceeding any part of it stops the run.
Limits#
| Time | API calls | Memory | |
|---|---|---|---|
| Backend scripts — manual, scheduled, event, item menu | 30 s | 100 | 50 MB |
| Save hooks | 5 s | 100 | 50 MB |
| Scripted charts and scripted widgets | 10 s | 50 | 25 MB |
Time is wall-clock time for the whole run, including the time spent waiting on fetch. Memory is sampled while the script runs, so treat the figure as a ceiling, not an exact allowance.
Only fetch() and secrets.get() count as API calls. Reading data — group.queryItems, getField, getMembers — and writing it — setField, createItem, addComment — do not.
Files have their own cap: a script can read or attach files of up to 10 MB, and a fetch response may be up to 10 MB. See Files and attachments.
Tip
One broad query is cheaper and faster than many narrow ones: fetch the items once with group.queryItems, then group and count them in memory with api.groupBy / api.aggregate or plain loops.
A save hook runs inside the save a person is waiting on, so its time budget is 5 seconds whatever the script’s own limit. A hook that runs out of time fails like any other: its changes are dropped and the save still succeeds. Keep hooks short, and move slow work — calls to external services especially — to an event script, which runs in the background.
How errors surface#
| Where the script runs | Where you see a failure |
|---|---|
| Manual run | the script list shows the run’s status; output and log lines are in the execution history |
| Scheduled and event scripts | the execution history |
| Save hook | the execution history; the person’s save still succeeds without the hook’s changes |
| Item menu script | a notification to the person who ran it, and the execution history |
| Scripted chart or widget | an error box in the tile, visible to the viewer, and the widget’s Recent runs |
The execution history keeps, for every backend run, its status (success, failed, timeout, cancelled), duration, output, error and the lines written with log(). Open it from the script’s page in group administration.
A scripted chart or widget runs as each person who views it, so every render is its own run. Its Recent runs — under the code editor in the widget’s configuration — list each run’s status, duration, the error the tile showed and the lines written with log(), with the name of the person it ran as. You see your own runs; the group’s administrators see everyone’s, which is how you find out why a chart fails for one viewer and not for you.
Errors in JavaScript#
| Kind | What happens |
|---|---|
| Syntax error | the script cannot be saved |
An uncaught exception — throw, calling something that does not exist | the run stops and fails with the message and line |
A failed write — setField, createItem, addAttachment, … | nothing throws: the method returns {success: false, error}, and the run continues |
A malformed query in group.queryItems | throws, with the parser’s explanation |
readAttachment on a file that is not on the item | throws |
fetch network failure | throws; an HTTP error status does not — check r.ok |
| A limit exceeded | the run stops with a limit error |
Because writes do not throw, check the result where a failure matters:
const r = item.setField("approvedBy", userId);
if (!r.success) {
log("could not record approval:", r.error);
}
Use try/catch around code that can throw when the rest of the run should continue:
let items = [];
try {
items = group.queryItems(pageVars.get("filter") || "");
} catch (e) {
log("bad filter:", e.message);
}
Errors in Gonja templates#
A template that fails to parse, calls an unknown function, runs a malformed query or reads a file that is not on the item stops rendering, and the tile shows the error. Missing values do not fail: an unset field or variable renders as an empty string, and date() / datetime() print nothing for an unset date.
Debugging#
log(...)writes lines to the execution history, next to the script’s final value; it accepts any value and prints objects as JSON.- Running a script manually and opening its execution log shows the final value and every
log()line — the quickest way to try a query or a transformation before wiring the script to a trigger. - Write methods say why they failed — log
r.error. - Permissions apply to scripts: a query returns only what the script’s user may see, a field that user’s roles hide reads as unset, and a write to a field that user cannot edit is refused. See Backend scripts for which user each trigger runs as.