DEV: Unsilence this-property-fallback deprecation (#29855)

This one has the potential to be very noisy, so a special dedupliation handler is introduced.

https://meta.discourse.org/t/337276
This commit is contained in:
David Taylor 2024-11-21 16:35:05 +00:00 committed by GitHub
parent 6e5d4ee492
commit 019ba099c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 6 deletions

View File

@ -1,8 +1,4 @@
const DEPRECATION_WORKFLOW = [
{
handler: "silence",
matchId: "ember-this-fallback.this-property-fallback",
},
{ handler: "silence", matchId: "discourse.select-kit" },
{
handler: "silence",

View File

@ -0,0 +1,44 @@
import { registerDeprecationHandler } from "@ember/debug";
import { consolePrefix, getThemeInfo } from "discourse/lib/source-identifier";
let registered = false;
const seenMessages = new Set();
export default {
initialize() {
if (registered) {
return;
}
registerDeprecationHandler((message, options, next) => {
if (options.id !== "ember-this-fallback.this-property-fallback") {
return;
}
// These errors don't have useful backtraces, but we can parse theme/plugin
// info from the message itself.
const pluginMatch = message.match(/\/plugins\/([\w-]+)\//)?.[1];
const themeIdMatch = message.match(/\/theme-(\d+)\//)?.[1];
if (pluginMatch || themeIdMatch) {
const source = {
type: pluginMatch ? "plugin" : "theme",
name: pluginMatch || getThemeInfo(parseInt(themeIdMatch, 10)),
id: themeIdMatch,
};
options.source = source;
message = `${consolePrefix(null, source)} ${message}`;
}
// Only print each message once, to avoid flood of console noise
if (seenMessages.has(message)) {
return;
}
seenMessages.add(message);
options.url = "https://meta.discourse.org/t/337276";
next(message, options);
});
registered = true;
},
};

View File

@ -1,4 +1,4 @@
import DEBUG from "@glimmer/env";
import { DEBUG } from "@glimmer/env";
import { waitForPromise } from "@ember/test-waiters";
import mergeHTMLPlugin from "discourse/lib/highlight-syntax-merge-html-plugin";
import { isTesting } from "discourse-common/config/environment";

View File

@ -1,3 +1,4 @@
import { DEBUG } from "@glimmer/env";
import { registerDeprecationHandler } from "@ember/debug";
import Service, { service } from "@ember/service";
import { addGlobalNotice } from "discourse/components/global-notice";
@ -19,9 +20,13 @@ export const CRITICAL_DEPRECATIONS = [
"discourse.plugin-outlet-tag-name",
"discourse.plugin-outlet-parent-view",
"discourse.d-button-action-string",
/^(?!discourse\.)/, // All unsilenced ember deprecations
];
if (DEBUG) {
// used in system specs
CRITICAL_DEPRECATIONS.push("fake-deprecation");
}
// Deprecation handling APIs don't have any way to unregister handlers, so we set up permanent
// handlers and link them up to the application lifecycle using module-local state.
let handler;