diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
index e355850..1aabeef 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
@@ -321,17 +321,17 @@ public function next() {
         $row->setIdMap($id_map);
       }
 
+      // Preparing the row gives source plugins the chance to skip.
+      if ($this->prepareRow($row) === FALSE) {
+        continue;
+      }
+
       // Clear any previous messages for this row before potentially adding
       // new ones.
       if (!empty($this->currentSourceIds)) {
         $this->idMap->delete($this->currentSourceIds, TRUE);
       }
 
-      // Preparing the row gives source plugins the chance to skip.
-      if ($this->prepareRow($row) === FALSE) {
-        continue;
-      }
-
       // Check whether the row needs processing.
       // 1. This row has not been imported yet.
       // 2. Explicitly set to update.
