Troubleshooting Code (JavaScript) on Zapier

Use this article to troubleshoot common issues when using Code (JavaScript) by Zapier. Find your problem below and follow the steps to fix it.

Error messages

These are specific error messages you might encounter when running JavaScript or Python Code steps.

Scripting payload too large

Symptom

Your Code step fails with the error "Scripting payload too large."

Causes

The environment in which Code steps run (AWS Lambda) has an I/O limit of 6 MB. The total size of the code and the data it processes cannot exceed that limit.

How to fix it

  1. Reduce the amount of data your function returns. Return only the keys you need instead of entire JSON structures.
  2. If you are processing a large API response, filter or trim the data before returning it.
Process exited before completing request

Symptom

Your Code step fails with the error "Process exited before completing request."

Causes

  • Your script completes without calling callback.
  • Your fetch().then() chain does not have a .catch() for errors, causing the process to exit silently.

How to fix it

  1. Add .catch(callback) to your fetch().then() chain so errors are passed as the first argument.
  2. Alternatively, use await with a Code step to avoid callback issues entirely.
NoneType object does not support item assignment

Symptom

Your Code step fails with the error "'NoneType' object does not support item assignment."

Causes

  • You used indexed assignment on a value that is None, for example my_dict[key] = value when my_dict is None.
  • A variable you expected to be a dictionary or list was never initialized, or came back as None from input_data or an earlier step.

How to fix it

  1. Initialize containers before you assign into them, for example assign {} or [] first if you are building a dict or list.
  2. When reading input_data, use .get() or check is not None before you assign into nested structures.
  3. Avoid reusing variable names in a way that overwrites Zapier-provided values with None.
You cannot return more than 250 items from a Code action

Symptom

Your Code step fails with the error "You cannot return more than 250 items from a Code action."

Causes

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

How to fix it

  1. Reduce the number of items in your return object to 250 or fewer.
  2. If you need to process more items, split the work across multiple Code steps or filter the data before returning it.
Time and memory limits

Symptom

Your Code step fails with a timeout or memory error.

Causes

Code steps have rate limits and throttling that vary by plan. Your Zap will error if it exceeds these limits.

How to fix it

  1. Review the Code by Zapier rate limits for your plan.
  2. Optimize your code to reduce execution time and memory usage.
  3. If you are using third-party packages, large packages can increase install time. Try using a smaller, more focused package.

Zapier SDK errors

These issues relate to using the Zapier SDK in Code steps.

Authentication failed

Symptom

Your Code step fails with the error "Authentication failed" when using the Zapier SDK.

Causes

The app connection used by the SDK has expired or been revoked.

How to fix it

  1. Reconnect the app connection in the Zap editor.
  2. Confirm the connection is active in your app connections.
Connection not found

Symptom

Your Code step fails with the error "Connection not found" when using the Zapier SDK.

Causes

  • The connection is not selected in the Code step's connection picker.
  • The appKey in your code does not match the connected app (for example, using "Slack" instead of "slack").

How to fix it

  1. Open the Code step and check the connection picker to confirm the correct connection is selected.
  2. Verify the appKey in your code matches the app you connected. Use the Zapier SDK CLI to confirm the correct app key. If you have not logged in on this computer yet, run npx @zapier/zapier-sdk-cli login, then run npx @zapier/zapier-sdk-cli list-connections --owner me in your local terminal.

Debugging

If your Code step produces an error you cannot identify, use a linter to find issues in your code. Tools like JSHint and ESLint can help. Paste your code directly into these tools.

Example: Using a linter to find a bug

If your code has an error about response not being defined:

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 */

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

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.

Still need help?

If this article did not fix the issue:

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