In NetSuite, a Map/Reduce script is not automatically prevented from running again if it encounters a timeout error. Instead, the behavior depends on which stage the timeout occurs:
- Get Input Data Stage: If a timeout occurs here, the entire script will fail, and no further processing will take place. You will need to reschedule or manually restart the script.
- Map or Reduce Stage: If a timeout occurs in either of these stages, only the particular Map or Reduce function that timed out will fail. The script will continue processing other records. The failed record can be retried automatically if the script is rescheduled.
- Summarize Stage: If a timeout occurs here, the script will be marked as failed. You may need to handle errors gracefully within the summarize function to avoid this.
Automatic Rescheduling
If you enable “Automatically Reschedule” in the script deployment, the Map/Reduce script can automatically reschedule itself if it hits governance limits or timeouts. This allows it to pick up where it left off without manual intervention. However, if a timeout occurs in the getInputData stage, automatic rescheduling will not occur.
Best Practices to Avoid Timeouts
- Chunk Data: Break large datasets into smaller chunks.
- Governance Checks: Monitor governance units and reschedule early if necessary.
- Yielding the Script: Use
task.yield()to avoid timeouts during long processing.