diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs
index 1bfd30642..682895abc 100644
--- a/crates/engine/src/tests/plugins.rs
+++ b/crates/engine/src/tests/plugins.rs
@@ -439,6 +439,24 @@ fn a_painted_effect_on_a_fill_and_refused_results() {
}
}
+/// A result refused for a swatch the document doesn't have stays cached: once the document has the
+/// swatch, the next check of that result clears the error.
+#[test]
+fn a_refused_swatch_s_error_clears_once_the_document_has_the_swatch() {
+ let mut s = session();
+ let id = rect(&mut s, 10.0, "#ff0000");
+ let mut later = solid("#00ff00");
+ later["swatch"] = json!("Later");
+ let output = json!({"objects": [{"path": square_at(40.0), "fills": [later]}]}).to_string();
+ install_wat(&mut s, &tpl::returning(&painting("test.engine.laterswatch", true), &output));
+ run(&mut s, "effect.apply", json!({"ids": [id.0], "effect": "plugin.test.engine.laterswatch"}));
+ drawn(&s);
+ assert!(run(&mut s, "plugin.info", json!({"id": "test.engine.laterswatch"}))["lastError"].is_string());
+ run(&mut s, "swatch.new", json!({"name": "Later", "color": "#00ff00", "global": true}));
+ drawn(&s);
+ assert_eq!(run(&mut s, "plugin.info", json!({"id": "test.engine.laterswatch"}))["lastError"], Value::Null);
+}
+
/// A painted effect on a group may link its pieces to the document's swatches.
#[test]
fn a_painted_group_effect_links_to_the_document_s_swatches() {
diff --git a/crates/plugins/src/effect.rs b/crates/plugins/src/effect.rs
index 0eded4070..fee13330e 100644
--- a/crates/plugins/src/effect.rs
+++ b/crates/plugins/src/effect.rs
@@ -174,7 +174,23 @@ fn weight(key: &Key, out: Option<&Out>) -> usize {
};
anchors(&key.path) + out + (key.params.len() + key.paints.len()) / 50 + 1
}
-static ERRORS: Mutex