From d024b70528232818ee573394e42ca47cc28ce8a8 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Thu, 25 Feb 2021 11:44:49 +0100 Subject: [PATCH] fix: don't print deprecation warning for touchNode for the sample plugin multiple times (#29745) --- packages/gatsby/src/redux/actions/public.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/src/redux/actions/public.js b/packages/gatsby/src/redux/actions/public.js index 3a78fe946b0a3..9aa3c016985b0 100644 --- a/packages/gatsby/src/redux/actions/public.js +++ b/packages/gatsby/src/redux/actions/public.js @@ -803,6 +803,8 @@ actions.createNode = (...args) => dispatch => { }) } +const touchNodeDeprecationWarningDisplayedMessages = new Set() + /** * "Touch" a node. Tells Gatsby a node still exists and shouldn't * be garbage collected. Primarily useful for source plugins fetching @@ -824,7 +826,10 @@ actions.touchNode = (node: any, plugin?: Plugin) => { msg = msg + ` "touchNode" was called by ${plugin.name}` } - report.warn(msg) + if (!touchNodeDeprecationWarningDisplayedMessages.has(msg)) { + report.warn(msg) + touchNodeDeprecationWarningDisplayedMessages.add(msg) + } node = getNode(node.nodeId) }