--- a/IRC.pm
+++ b/IRC.pm
@@ -138,7 +138,7 @@
   # we don't want to bother waiting on input or running
   # scheduled events if we're just flushing the output queue
   # so we bail out here
-  return if $caller eq 'Net::IRC::flush_output_queue';
+  return if defined($caller) and $caller eq 'Net::IRC::flush_output_queue';
 
   # Check the queue for scheduled events to run.
   if(!$self->schedulequeue->is_empty) {
