Unreliable Wifi on Cyanogenmod
The behaviour you describe could plausibly be caused by a bug in the Wi-Fi software on your phone, if sleeping the Wi-Fi transceiver makes it forget something necessary to make the connection work (such as the WPA keys).

This is the kind of thing you have to expect when you use a pre-release version of a ROM. Nightly builds simply aren't suitable for day-to-day use, because it's a bit of a lottery what bugs will have been added from one build to the next. Switch to a stable build instead.