If MediaWiki API replies with an error, commons-selection.js can't deal with it. The user then sees "Loading..." forever. An error message would do. The error message should recommend disconnecting and reconnecting of Wikimedia account.
Example error reply, happens when user have old OAuth token.
{"error":{"code":"mwoauth-invalid-authorization","info":"The authorization headers in your request are not valid: No approved grant was found for that authorization token.","*":"See https://commons.wikimedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."},"servedby":"mw1228"}