Skip to content

Scripts: troubleshooting

The editor and the check on publishing report every problem of a script with a code from ACR-S001 on. Learn more on a marker in the editor leads to the code’s entry on this page. An error keeps the workflow from being published, a warning doesn’t.

The script can’t be read: check the syntax at this place. Error.

The code isn’t valid TypeScript, for example because of a missing bracket or a quote that isn’t closed. The message names the place and TypeScript’s description. The cause is often a line before it.

The script must export defineScript(…) as its default export. Error.

Every script file exports exactly one defineScript(…) with export default. Write export default defineScript({ hook: …, run(ctx) { … } }); and import defineScript from '@acriva/workflow-sdk'.

Type error: the value doesn’t fit the type the SDK or the workspace’s types expect here. Error.

TypeScript’s message after it says what doesn’t fit. The most common cases are under Common type errors. // @ts-nocheck is this error as well, because it would turn off the check of the whole script.

A script may import only ‘@acriva/workflow-sdk’. Error.

A script imports nothing but the SDK, no other script file and no library. /// <reference …> isn’t allowed either. Write what you need more than once as a function in the same file.

The hook in the code isn’t the hook of the step. Error.

hook in defineScript must be the hook the script step names in the designer. Make the two match.

This return value isn’t declared on the step, or it has another type. Error.

A script returns only the return values its step declares, with their type. Declare the return value on the step, or change outputs in the code to match the step.

This hook doesn’t allow this effect. A script before an approval only reads and may add a hint. Error.

On beforeApproval a script may only call ctx.hint; setField, addTag, fileInto, notify, branch and result don’t exist there. Which hook allows what is under Hooks.

This value isn’t one of the branch’s declared values, so no exit takes it. Error.

ctx.branch takes only one of the values of the fixed choice the step has as its exits. Check the spelling, or add the value on the step.

This field isn’t declared as an input of the step. Error.

A script reads only the fields its step names as inputs. Add the field to the step’s inputs.

A script can’t set this field: it isn’t declared, or Finance reads it for an invoice. Error.

A script sets only fields of the document type that it may set. No script sets the fields Finance reads for an incoming invoice (such as the amounts and the vendor). After an approval, it sets only an empty field that the workflow declares.

This loop has no visible bound. A script ends when it uses up its engine time. Warning.

The warning comes for while (true) and every while loop with a fixed condition, every do … while loop, and a for loop without a condition or without an update: they can run forever. A script that uses up its computing time fails with limit-engine-time. Give the loop a fixed bound, or loop over a list (for (const x of list)).

‘fetch’ isn’t allowed in scripts. Use a data source (ctx.sources). Error.

Scripts have no network. A script reads external data through a data source that your workspace has set up: await ctx.sources.get('erp', { query: { … } }). The quick fix Use a data source marks the call for you to replace with ctx.sources.get.

Scripts have no network access. Use a data source (ctx.sources). Error.

This applies to XMLHttpRequest, WebSocket and every other way into the network. Read external data through a data source as under ACR-S012.

Scripts can’t create code at run time (eval, Function). Error.

eval, new Function(…) and similar ways to create code from text don’t exist in scripts. Write the code directly.

Scripts have no timers. A workflow waits with a timer step. Error.

setTimeout, setInterval and the like don’t exist. If the workflow should wait, put a Timer step before or after it; a script on the hook onTimer runs after a deadline.

Scripts can’t load modules (require, import()). Import from ‘@acriva/workflow-sdk’. Error.

require(…) and import(…) load nothing. Import from '@acriva/workflow-sdk' at the top of the file.

This variable is never used. Warning.

Remove the variable, or start its name with _ if it should stay.

The script is larger than 64 KB. Error.

A script has at most 64 KB. Split the work across several script steps, or put large fixed lists into a data table.

This SDK version isn’t supported. Error.

The script names a version of the SDK that this version of Acriva doesn’t know. Save the script with the current SDK version, which the editor shows.

This data source isn’t declared as an input of the step. Error.

A script calls only the data sources its step names as inputs. Add the data source to the step’s inputs.

This data table isn’t declared as an input of the step. Error.

A script reads only the data tables its step names as inputs. Add the data table to the step’s inputs. A run that reads an undeclared data table fails with table-not-declared.

The check didn’t finish: it took longer than 10 seconds or ran out of memory. Simplify the script’s types and check it again. Error.

The check of a script has 10 seconds. Deeply nested or recursive types can take longer. Replace complicated types you wrote yourself with simpler ones, and save the script again.

  • Type 'string' is not assignable to type 'Money' (or number): an amount is a number, not a text. Read a text with money.parse('1.249,50 €'), which returns null when the text isn’t an amount.
  • Property '…' does not exist on type 'Readonly<DocumentFields>': the field doesn’t exist, or the step doesn’t name it as an input. Check the spelling with the completion, and add the field to the inputs.
  • '…' is possibly 'null': a field that isn’t required can be empty. Check it first: const amount = ctx.document.fields.grossAmount; if (amount == null) return;.
  • Argument of type '"…"' is not assignable to parameter of type … on addTag, fileInto or notify: the tag, the file type or the role doesn’t exist in the workspace. The completion shows which ones do.
  • Property 'setField' does not exist on type 'ScriptContext': the script is on the hook beforeApproval, which only reads (see ACR-S007).
  • A day compared with a point in time: date fields are days ('2026-10-14'), ctx.now() is a point in time. Compare days with ctx.today(), and compute with date.addDays and date.daysBetween.

When a script exceeds a limit, or fails in another way, its run fails: Acriva doesn’t apply its changes (when it refuses a single change, the ones applied before it stay), the workflow goes to the step’s failure exit or, without one, to the default next step, and the run shows its code. The test run shows the same code without changing anything.

Code Meaning What helps
script-exception The script threw an exception; the script’s message and the place are shown with it. Handle the case, such as an empty field.
script-syntax The code can’t be run. Check the script in the editor; the check names the place.
script-import The script tried to load a module. See ACR-S016.
script-never-settled run neither returned nor threw, such as a Promise that never finishes. Return from run, and use await only on ctx.sources and ctx.tables.
limit-engine-time More than 2 seconds of computing time. Bound your loops (ACR-S011), and don’t compute large things in the script.
limit-wall-clock The run took more than 45 seconds in total. Call fewer or faster data sources.
limit-memory More than 64 MB of memory. Don’t keep large lists or texts in memory.
limit-statements, limit-recursion Too many statements or too deep a recursion. Write a recursion as a loop.
limit-regex A regular expression took longer than 250 milliseconds. Simplify the expression, for example without nested repetitions like (a+)+.
limit-result, limit-log The return values and changes are larger than 256 KB, or the console has more than 1,000 lines or 64 KB. Write less with ctx.log, and return less.
limit-table-lookups More than 50 lookups in data tables. Look up several rows at once with ctx.tables.query.
table-not-declared A data table the step doesn’t name as an input. See ACR-S021.
effect-refused Acriva refused a change: a value that doesn’t fit the field, an undeclared exit, a size over its limit. Check the values the script sets against the fields, and the exits against the step.
reference-unresolved A field, tag, file, member or role the script names no longer exists. Change the script, and publish again.
limit-concurrency Your workspace’s 20 concurrent runs were taken the whole time. The step goes on as after any failed run; avoid many long runs at once, such as with slow data sources.
runner-lost, runner-unreachable The sandbox crashed during the run or couldn’t be reached. Usually a temporary problem; check the script for too much memory or computing time.
quarantined The script crashed the sandbox three times and is blocked for your workspace. Fix the cause, and publish a new version.
sdk-version-unsupported The sandbox doesn’t know the script’s SDK version. See ACR-S019.

A data source that doesn’t answer or reaches its limit doesn’t end the run: ctx.sources.get then returns { ok: false, error }, and the script decides what to do.

  • A script has an error. The app names each script with its messages; fix them in the editor and publish again.
  • A script step names a file the draft doesn’t have. Create the script, or choose another file on the step.
  • The scripts use different SDK versions. All scripts of a version use one SDK version. Save every script with the same SDK version.
  • The check can’t be reached right now. Acriva never publishes a script without its check. Try again in a few minutes.
  • Too many checks. A person can start 30 checks a minute, saving and publishing included. Wait a moment.