Problem/Motivation

Currently ajax errors are only visible in the browser console. This is confusing for non-technical users because there's no indication in the UI that an error happened. Providing easy to understand error messages is often listed as one of the most important UX considerations.

Proposed resolution

Display the following text:,

Oops, something went wrong. Check your browser's developer console for more details.

Remaining tasks

-

User interface changes

In case of an ajax error, the error will be visible in the UI.

API changes

-

Data model changes

-

Issue fork drupal-2987444

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lauriii created an issue. See original summary.

edysmp’s picture

+1

tim.plunkett’s picture

Category: Bug report » Feature request

+1

GrandmaGlassesRopeMan’s picture

Status: Active » Needs review
Issue tags: +JavaScript, +Needs tests
StatusFileSize
new3.78 KB

- enable `ajax_test` module
- visit `/ajax-test/exception-link`
- see error

Status: Needs review » Needs work

The last submitted patch, 4: 2987444-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

lauriii’s picture

The test failure is caused by the fact that big pipe has now dependency to drupal.announce which appends some markup to the body. Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMultipleClosingBodies_2678662 is testing whether the big pipe stop signal was presented right before the closing body and HTML tags. I'm not sure if that is an implementation detail or requirement for the big pipe. This is not a new problem since if something on the page already depended on drupal.announce, this same situation would occur.

lauriii’s picture

+++ b/core/misc/ajax.es6.js
@@ -172,11 +172,22 @@
+    // @todo: Do we want to respect their logging option in Drupal?

I don't think we have to worry about this as part of this issue. This is something we should think about as a separate feature in the future.

I misunderstood the @todo. I thought this was about storing JavaScript errors in the logs but @drpal explained that this is about the "Error messages to display" setting in the logging and errors settings page. It seems like it is possible to disable showing error messages altogether. I agree that we probably should honor that setting.

As a next step, we should expose the setting in drupalSettings and adjust the error handling according to that.

lauriii’s picture

Title: Ajax errors are not visible in the UI » Ajax errors are not communicated through the UI

We discussed this with @drpal and @tedbow and agreed that we should add a new configuration to the UI that would allow configuring whether there should be ajax error visible for users. This will be configured so that existing sites would have errors turned off, but any new sites would have them turned on by default. Also, the texts in the UI should encourage users to have this configuration turned on opposed to the PHP error messages since this is UX enhancement, and won't include any potentially private information.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ckrina’s picture

This will be configured so that existing sites would have errors turned off, but any new sites would have them turned on by default. Also, the texts in the UI should encourage users to have this configuration turned on opposed to the PHP error messages since this is UX enhancement

+1 to this

Since we already have the form Configuration / Site settings it could go there initially, mainly because we already have the "Default 403 (access denied) page" and "Default 404 (not found) page", but I'm not 100% sure. This maybe could go under Configuration / User interface too if we add other UI changes that would make sense together with this.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

lauriii’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lauriii’s picture

Issue tags: +Field UX

hooroomoo made their first commit to this issue’s fork.

tim.plunkett’s picture

Running Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::testNarrowWidth locally I also see a failure.

core/themes/olivero/js/messages.js is trying to write to Drupal.olivero
core/themes/olivero/js/navigation-utils.js defines Drupal.olivero

and they are running in that order!
I'm not sure the best way to get them in the correct order.

hooroomoo’s picture

Status: Needs work » Needs review

tim.plunkett’s picture

Issue tags: -Needs tests

I love that this surfaced and fixed a bug!

I'd mark it RTBC, but #10 is not addressed as this is not yet configurable. Is that still needed first?

tim.plunkett’s picture

Status: Needs review » Needs work

Oh lol, Nightwatch tests are still failing. Glad I didn't RTBC :D

hooroomoo’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Reviewing MR 3609

Left a comment but why wouldn't olivero/global-styling not be there?

Also I see the new ajax_test routes but don't see the test that calls them? Unless there's something that loops through all the routes? But couldn't find that.

smustgrave’s picture

Also to echo what tim.plunkett said. This sounds like a great feature to get included!

tim.plunkett’s picture

Issue tags: +Needs tests

The test routes were added in #4 but only for manual testing. You're right that we need an automated test to use them. Leaving the other response on the MR.

hooroomoo’s picture

Status: Needs work » Needs review
lauriii’s picture

Category: Feature request » Bug report

Discussed with @ckrina who is one of the Usability topic maintainers. We agreed that this is a net-win as in all situations where user is triggering an action, and it fails to execute. Adding new error messages may make us discover some bugs in other systems but that's not the fault of the error, in fact it's the opposite since it will help us expose those use cases and work on the root cause.

Quoting an article from Nielsen Norman:

Good error message should include:

Explicit indication that something has gone wrong. The very worst error messages are those that don't exist. When users make mistakes and get no feedback, they're completely lost.

Human-readable language, instead of obscure codes or abbreviations such as "an error of type 2 has occurred."

Based on this, it would be great if we could still iterate on the specific wording of the message. I think we should at least try to remove mention of ajax since it's not language that users are accustomed to.

smustgrave’s picture

Status: Needs review » Needs work

Moving to NW per #32.

Leaving the needs tests tag incase any additional coverage is needed.

hooroomoo’s picture

Status: Needs work » Needs review
StatusFileSize
new39.79 KB

An AJAX system error has occurred. -> Oops, something went wrong. Check the console for more details.

Updated message string to remove the mention of AJAX and point to the console if the user wants more information.

tim.plunkett’s picture

Issue tags: -Needs tests
Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLibraryTest::testButton
Failed asserting that a NULL is not empty.

I got this failure once in every 10 local test runs.

I think this is described here as well #3346122-4: ckeditor test failures causing pain for unrelated patches


Tests were added in
b1f1df3b - WIP: add test that currently fails

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Get the same results as #34 using the new routes provided.

Points from #32 appear to be addressed.

Think

it would be great if we could still iterate on the specific wording of the message

could be a follow up?

tim.plunkett’s picture

+1 for RTBC, the wording changed in the last commit and I think it's shippable as-is

borisson_’s picture

I agree with #37, the wording is now less technical. Looks great.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Hm, the problem statement is this:

Currently ajax errors are only visible in the browser console. This is confusing for non-technical users because there's no indication in the UI that an error happened.

Looking at the error message proposed, I think "the console" would not be evident to a non-technical user. Is it a Drupal backend concept or in their command line terminal? I think "your browser's developer console" or something along those lines would be easier to google for. It would be nice if there would be a product agnostic page that we could link to, like https://balsamiq.com/support/faqs/browserconsole/ but not under Balsamiq (nothing against Balsamiq but you get the idea). Otherwise I think "your browser's developer console" makes it much more specific and is good basis to google for. I am not attached to these specific words, but IMHO "the console" is not enough for a non-technical user.

Rishabh Vishwakarma made their first commit to this issue’s fork.

hooroomoo’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed the message is now

Oops, something went wrong. Check your browser's developer console for more details.

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work

It looks like there was a decision to make this configurable, which I don't see in the MR. Either that should be added, or someone can point out where that requirement changed and switch this back to RTBC.

lauriii’s picture

Status: Needs work » Reviewed & tested by the community

Reading it back, I realize that #32 may have been unclear. The reason I made that comment was to try to make a point that we shouldn't make it configurable because having these error messages are essential for UX. I discussed that with @ckrina as well to make sure that she didn't have concerns on that.

quietone’s picture

Issue summary: View changes

I agree that this is a step in the right direction.

I am concerned that the message is not helpful to a non technical user because it suggests that they learn how to use a technical tool. And they will need to search for how to do that for their browser. Instead can we change this to a message that they should contact the site admin?

bnjmnm’s picture

Refining that message content could potentially delay what is a very helpful improvement. I created a followup to focus on adjusting that language after this lands, which lets this feature get in while still providing us with a place to potentially improve that messaging.

#3349901: Determine if there is a better message for AJAX errors

  • lauriii committed e492ae34 on 10.1.x
    Issue #2987444 by hooroomoo, lauriii, bnjmnm, alwaysworking, tim....
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Created and published a CR for this.

Committed e492ae3 and pushed to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tedbow’s picture

So I think this issue broke Javascript messages on batch forms. But there were no tests for that so it wasn't going to be caught.

Created #3392196: Exceptions in batch no longer are shown on the page when Javascript is disabled we have a test there and are working on a fix. Any help would be appreciated.

aporie’s picture

Hi,

I might be in the wrong here, but why assuming that every Ajax response should return a 200 is the expected behavior for all websites.
Sometimes you might want your user to be able to click an ajax link which will return a 403 for example. Then you purposely display a message to your user that they are not allowed to perform the action.

With this addition, websites have now a non-needed, non-user-friendly message displayed to users on expected 403.

Maybe a good addition would be to make this feature optional (as per improving the message in #3349901: Determine if there is a better message for AJAX errors)?

tаo’s picture

StatusFileSize
new947 bytes

It makes AJAX error behaviors more configurable.