Page MenuHomePhabricator

Catch exceptions from mw.hook handlers
Closed, ResolvedPublic

Description

When a hook throws an exception all other subscribers of the hook get also stopped.

Examples

mw.hook( 'wikipage.content' ).add( function ( $content ) {
	throw new Error( 'Foo' );
} );

blocks all extensions and gadgets that also use the hook 'wikipage.content'.

The reason for T220308 was an exception in Maps (Kartographer) that blocked MediaWiki-extensions-TocTree.

Expected behavior

An exception in a subscriber of a hook should not prevent that other subscribers of the hook gets fired.

Event Timeline

Krinkle renamed this task from Catch exceptions on mw.hook to Catch exceptions from mw.hook handlers.May 20 2019, 6:52 PM
Krinkle triaged this task as Low priority.
Krinkle moved this task from Inbox to Accepted Enhancement on the MediaWiki-ResourceLoader board.
Krinkle moved this task from Inbox to Backlog: Maintenance on the Performance-Team board.
Krinkle added a project: patch-welcome.

Hey @Fomafix ! Does we have to use $() instead of mw.hook()...??

Change 674728 had a related patch set uploaded (by Krinkle; author: Krinkle):
[mediawiki/core@master] mediawiki.base: Clean up mw.hook unit tests

https://gerrit.wikimedia.org/r/674728

Change 674730 had a related patch set uploaded (by Krinkle; author: Krinkle):
[mediawiki/core@master] mediawiki.base: Convert mw.hook from jQuery.Callbacks() to own code

https://gerrit.wikimedia.org/r/674730

Change 674731 had a related patch set uploaded (by Krinkle; author: Krinkle):
[mediawiki/core@master] mediawiki.base: Catch exceptions between mw.hook() handlers

https://gerrit.wikimedia.org/r/674731

Change 678810 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/core@master] mediawiki.base: Add unit tests to mw.hooks

https://gerrit.wikimedia.org/r/678810

Change 674728 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.base: Clean up mw.hook unit tests

https://gerrit.wikimedia.org/r/674728

Change 674730 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.base: Convert mw.hook from jQuery.Callbacks() to own code

https://gerrit.wikimedia.org/r/674730

Change 674731 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.base: Catch exceptions between mw.hook() handlers

https://gerrit.wikimedia.org/r/674731

Change 678810 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.base: Add unit tests to mw.hooks

https://gerrit.wikimedia.org/r/678810