diff --git a/src/TopicTree.h b/src/TopicTree.h index 73eef9731..a8371283d 100644 --- a/src/TopicTree.h +++ b/src/TopicTree.h @@ -252,6 +252,11 @@ struct TopicTree { /* This one always resets needsDrainage before it calls any cb's. * Otherwise we would stackoverflow when sending after publish but before drain. */ drainImpl(s); + + /* If we drained last subscriber, also clear outgoingMessages */ + if (!drainableSubscribers) { + outgoingMessages.clear(); + } } }