What is "AppleEvent timed out"?

This is an apple event error, which means that you are not allowed to execute more code because you are very slow.

For example, you are targeting the Finder to duplicate a folder, which has a size of 888 terabytes. After it is duplicated, you wish rename the new folder to “duplicate gotta hey!”. This is the code:

tell application "Finder"
	duplicate alias "path:to:really BIG folder:"
	set name of result to "duplicate gotta hey!"
end tell

The Finder will receive the order: “duplicate!” And AppleScript will wait for a response: “done, sir!”.

If AppleScript gets tired of waiting for an answer, it will time out and will die throwing the error “AppleEvent timed out”. So, the “set name…” line won’t be executed.

Actually, AS 1.9.1, AppleScript gets tired after 2 minutes. However, you can prevent this from happening using the following statement:

with timeout of (30 * 60) seconds
	tell application "Finder"
		duplicate alias "path:to:really BIG folder:"
		set name of result to "duplicate gotta hey!"
	end tell
end timeout

Now, AppleScript will get tired after 30 minutes!

Note that this error will happen only when you are targeting a process (eg, the Finder). However, if you use the following code…

set aFolder to (choose folder with prompt "Choose a folder, please...")

… If you were an irresolute folk, you could wait for 17 days before choosing a folder, and you wouldn’t receive a timeout error.