Function Timeout
Resolve timeout errors in Sanity Functions by adjusting the timeout duration.
When testing Compute Functions locally you may see a timeout error. For example:
npx sanity functions test log-event › Error: Error: Timeout: The process exceeded your current timeout limit of 10 seconds. Learn to adjust your blueprint's › timeout settings here: https://www.sanity.io/docs/help/functions-timeout
By default function execution time is set to 10 seconds, but may be configured down as low as 1 second and as high as 900 seconds (15 minutes).
You can experiment with different timeout values directly from the command line via the --timeout
flag.
npx sanity functions test log-event --timeout 15
This will increase the timeout value to 15 seconds.
Note: Your functions will likely run faster locally than in the cloud. Today's modern machines far outpace the capabilities of cloud runners. So expect to add a bit of padding in your timeout value to compensate.
Once you establish an appropriate timeout value, update your blueprint file.
import { defineBlueprint, defineDocumentFunction } from "@sanity/blueprints" export default defineBlueprint({ resources: [ defineDocumentFunction({ name: "log-event", timeout: 15, // Add your new timeout value }), ], })
Now the next time you test your function locally it will read the new timeout value from the blueprint.
Was this page helpful?