Error: Scripting payload too large
The environment in which your Code steps run (AWS Lambda) has an I/O limit of 6MB. 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 your return from your function. For instance, don't return an entire JSON structure, just the keys you need.
I keep getting "Process exited before completing request" - what gives?
9 times out of 10 this happens if your script completes without calling the callback
- the most common case is if your fetch().then()
doesn't 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 having to worry about this.
'NoneType' object does not support item assignment
This 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 some strange errors.
Requiring or Using External Libraries
Unfortunately you cannot require external libraries or install or import libraries commonly referred to as "npm modules". Only the standard node.js library and the fetch
package are available in the Code app. fetch
is already included in the namespace.
Time & 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.
I keep getting "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 do an amazing job of letting you know when things are broken - for example - we love http://jshint.com/ and ESLint. You can paste your code directly there! For example, let's say our code looks like this and we keep getting an error about response
not being defined:
// this is bad code - but we don't know why...
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 error is driving us crazy! Now in http://jshint.com/ we paste this (note the extra globals definition so jshint knows about Zapier's provided variables):
/* globals inputData, output: true, fetch, callback */
// this is bad code - but we don't know why...
fetch('http://example.com/')
.then(function(res) {
return res.text();
}).then(function(body) {
callback(null, {id: 1234, rawHTML: response});
}).catch(function(error) {
callback(error);
});
If we look at the results we see that response
is indeed incorrect! We should have used body
:
You can safely ignore any warnings about "unused variables" of inputData
, output
, fetch
or callback
! We provide those for your convenience - you don't need to use them. But if you see something else listed there - it might be a sign that you have a bug!