Possible race condition with READ()?

Hi there. I’m using Asterisk 1.8 with Lua 5.0.

I have a dialplan written in lua that behaves as an IVR. I play two prompts back to back which require the caller to make a selection. I racked my brain over a bug for the last few days, and think I resolved it. Previously, what was happening was that whatever input the user entered for at the first prompt was triggering the second prompt to not even play, because the value returned by the first read() statement was being counted as input for the second read() as well. If I put a wait(1) in between the two prompts, the second prompt works properly. Is there a more elegant way of ensuring that whatever internal I/O related mechanism in Asterisk is finished before playing the second prompt for the user?

I looked through the Asterisk changelogs to see if this may have been fixed since, but didn’t see anything.