Page MenuHomePhabricator

Log a warning when queuing a non-existent style module
Open, MediumPublic

Description

Non-existent modules are generally reported client-side in the browser console.

The server-side ClientHtml class doesn't require modules to exist. That's by design to accomodate ParserCache. […]

Instead, we generally handle this on the client-side instead, which also makes it more visible for the front-end developers that work on this code. When a module, or one of its dependencies, is not found in the registry, a warning is logged to the console. The browser doesn't have a way to emit console warnigns from a CSS response, however, so for style modules these currently end up silently ignored.

If we wanted the Parser to have a dependency on ResourceLoader, I suppose we could consider logging a warning server-side if during a fresh parse an added module is not known to the registry, but that feels a bit messy.

Another way might be to add small number of bytes client-side for these cases by letting them be included in the RLSTATE object we have for style module names, and then making sure that mw.loader.state() logs warnings for unknown modules.

Yet another way might be to build on the footer script we have in ClientHtml for styleDeprecations, which also produces console warnings. This has the benefit of requiring zero code in the startup client itself, and no additional code in the <head> either. Instead, it would generate exactly the code that is needed without any unused abstractions.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Krinkle triaged this task as Low priority.

@DannyS712 I don't remember why I created this task last month specifically. I vaguely remember us talking about something related to this. Did you want to give this a go? Feel free to unassign if not, no problem :)

Krinkle raised the priority of this task from Low to Medium.Oct 30 2021, 6:32 AM

@DannyS712 I don't remember why I created this task last month specifically. I vaguely remember us talking about something related to this. Did you want to give this a go? Feel free to unassign if not, no problem :)

Created because of T292244 - I was asking why there were no warnings for trying to enqueue a module that was removed

I can try to give this a go with the styleDeprecations approach, seems like the easiest and doesn't increase startup size

I'm sorry that I haven't handled this task. I recently returned from a long bout of unexpected inactivity, and while I plan to resume my contributions here on Phabricator its unfair to claim tasks that I might not work on when others may be interested in handling them. I'm removing myself as the assignee in a batch-action, but if someone feels that I really should be the one to handle this task feel free to re-assign me and I'll take a look.