Common problems with Code (Javascript) on Zapier

Error: Scripting payload too large

The environment in which your Code steps run (AWS Lambda) has an I/O limit of 6 MB. The total size of the code and the data processed by the code cannot exceed that. If you're hitting this error, try to limit the amount of data you return from your function. For instance, do not return an entire JSON structure, just the keys you need.

"Process exited before completing request" error

This typically happens when your script completes without calling callback. The most common case is when your fetch().then() does not have a .catch() for errors. A simple .catch(callback) will suffice because the error will be passed as the first argument. Alternatively, use await with a Node 8 code step to avoid this issue.

'NoneType' object does not support item assignment

This error shows up when you redefine some of the important variables in the function, namely callback. Lambda expects callback to be there to complete an async function, so if you've redefined it you'll get unexpected errors.

Using external libraries

You can add public npm packages to your Code step. Only ESM (ECMAScript Module) packages are supported. Packages that use only CommonJS (CJS) or require native modules will not work. The standard node.js library and the fetch package are also included by default.

Time and memory limits

There are different Code rate limits and throttling, depending on what Zapier plan you're on. Your Zap will error if it exceeds these limits.

"You cannot return more than 250 items from a Code action" error

Code steps are limited to returning 250 items in the output object.

Use a linter

Linters help you identify issues in your code. Tools like JSHint and ESLint are useful for debugging. You can paste your code directly into these tools.

For example, if your code has an error about response not being defined:

// this code has a bug
fetch('http://example.com/')
  .then(function(res) {
    return res.text();
  }).then(function(body) {
    callback(null, {id: 1234, rawHTML: response});
  }).catch(function(error) {
    callback(error);
  });

In JSHint, paste the code with the extra globals definition so the linter knows about Zapier's provided variables:

/* globals inputData, output: true, fetch, callback */

// this code has a bug
fetch('http://example.com/')
  .then(function(res) {
    return res.text();
  }).then(function(body) {
    callback(null, {id: 1234, rawHTML: response});
  }).catch(function(error) {
    callback(error);
  });

The linter results show that response is incorrect. The correct variable is body:

JSHint results showing the response variable is not defined

miscEye icon Note

You can safely ignore any warnings about "unused variables" for inputData, output, fetch, or callback. Zapier provides those for your convenience. However, if you notice other variables listed, it might indicate a bug in your code.

Was this article helpful?
3 out of 15 found this helpful