Script Technical Notes
This page covers advanced topics for script development including configuration options, execution limits, version control, and troubleshooting.
Configuration Options
Scripts accept configuration parameters that control execution behavior, resource access, and cost limits.
Runtime
runtimeExecution environment. Must be
"nodejs18"or"python3.11". Default:"nodejs18".
Timeout
timeoutMaximum execution time in seconds. Range: 1-300. Default: 30. Scripts exceeding this limit are terminated.
Memory
memoryMemory allocation in MB. Range: 128-3008. Default: 128. Higher memory allocation provides proportionally more CPU.
Max Cost Per Execution
maxCostPerExecutionMaximum cost per execution in USD. Default: 1.0. Executions exceeding this limit fail with a cost limit error.
Max Executions Per Day
maxExecutionsPerDayMaximum executions per 24-hour period. Default: 100. Scripts stop executing when this limit is reached until the next day.
Allowed Resources
allowedResourcesArray of resource IDs the script can access. Empty array (default) denies all resource access. See Resources for details.
Execution Limits
Platform Limits
- Maximum execution time: 300 seconds (5 minutes)
- Maximum memory: 3008 MB
- Maximum code size: 50 MB (including dependencies)
- Maximum response size: 6 MB
- Concurrent executions: 10 per script
Rate Limits
- Manual executions: 100 per minute
- Event-triggered executions: No limit (subject to cost controls)
- Cron executions: Based on cron schedule configuration
Cost Controls
Scripts automatically stop executing when cost limits are reached:
- Per-execution limit: Configurable via
maxCostPerExecution - Daily limit: Configurable via
maxExecutionsPerDay - Monthly budget: Set at account level
Version Control
Scripts maintain multiple versions, enabling safe deployments and rollbacks. Each version is immutable once created.
Creating Versions
Version Naming
Follow semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes to event structure or return format
- MINOR: New features, backward compatible
- PATCH: Bug fixes, no API changes
Examples:
1.0.0- Initial release1.1.0- Added new feature1.1.1- Fixed bug2.0.0- Breaking change
Deploying Versions
Deployments reference a specific version number, creating a new function deployment with that version's code. Only one version can be deployed at a time.
Rollback
To rollback to a previous version, deploy that version:
Marketplace Publishing
Scripts can be published to the Mirra marketplace with pricing models.
Publishing Requirements
- Script successfully deployed with working code
- Complete metadata (name, description, tags)
- Valid pricing configuration
- Tested execution with no errors
Pricing Models
Free
Pay-Per-Execution
Subscription
Publishing Process
Troubleshooting
Timeout Errors
When scripts exceed the timeout limit:
- Increase timeout configuration (up to 300 seconds)
- Optimize slow operations (database queries, API calls)
- Use caching to reduce redundant computations
- Break long-running tasks into smaller chunks
- Consider async/background processing for heavy workloads
Memory Errors
When scripts run out of memory:
- Increase memory allocation (up to 3008 MB)
- Process data in smaller batches
- Remove unnecessary variables and large objects
- Use streaming for large file processing
- Monitor memory usage during development
Cost Limit Errors
When executions exceed cost limits:
- Review resource usage (external API calls, LLM tokens)
- Increase
maxCostPerExecutionif justified - Optimize expensive operations
- Cache frequently accessed data
- Set up cost alerts and monitoring
Event Subscription Not Firing
When event-triggered scripts don't execute:
- Verify subscription is enabled
- Check filter conditions match event structure
- Test subscription with manual event trigger
- Review execution history for errors
- Ensure script is deployed (not draft)
Deployment Failures
When script deployment fails:
- Check for syntax errors in code
- Verify all required dependencies are installed
- Test code locally before deployment
- Review deployment logs for specific errors
- Ensure code size is under 50 MB
Best Practices
Code Organization
Error Handling
Logging
Testing
Performance
- Minimize cold starts: Keep initialization code outside the handler
- Reuse connections: Create database/API clients outside handler
- Use appropriate memory: Higher memory = more CPU
- Batch operations: Group multiple API calls together
- Cache results: Store frequently accessed data