You are here: Foswiki>Tasks Web>Item14265 (18 Feb 2017, GeorgeClark)Edit Attach

Item14265: NatEdit plugin leaves UI blocked after some save errors

pencil
Priority: Normal
Current State: Closed
Released In: 2.1.3
Target Release: patch
Applies To: Extension
Component: NatEditPlugin
Branches: Release02x01 master
Reported By: PaulMerchantJr
Waiting For:
Last Change By: GeorgeClark
In some circumstances, the NatEditPlugin's save AJAX calls may not complete successfully, but also may not receive a proper AJAX response. (Possible cases are network anomalies or, as I can reliably reproduce, the timeout of an SSO session cookie maintained by an Apache module I have in front of Foswiki.)

If this happens, clicking on the "Save and Continue" button leaves the "Saving...." modal message in the page and fails to display an error. I've tracked the problem to the ajaxSubmit call at line 912 of the query.natedit.js script. The error handler assumes xhr.responseText exists, and if it does not the script aborts. Similar code appears in the preview button handler. Testing for the presence of responseText before use works around this problem. The following patch also enhances the error message when no detailed message is available:

--- jquery.natedit.uncompressed.js.bak	2017-01-12 15:39:46.000000000 -0500
+++ jquery.natedit.uncompressed.js	2017-01-13 11:18:25.666957772 -0500
@@ -919,7 +919,10 @@
                 });
               },
               error: function(xhr, textStatus, errorThrown) {
-                var message = self.extractErrorMessage(xhr.responseText) || textStatus;
+                var message = xhr.responseText ? self.extractErrorMessage(xhr.responseText) : textStatus;
+                if (message == "error") {
+                  message = "Error: save failed.  Please save your content locally and reload this page.";
+				}
                 self.showMessage("error", message);
               },
               complete: function(xhr, textStatus) {
@@ -969,7 +972,10 @@
           });
         },
         error: function(xhr, textStatus, errorThrown) {
-          var message = self.extractErrorMessage(xhr.responseText) || textStatus;
+          var message = xhr.responseText ? self.extractErrorMessage(xhr.responseText) : textStatus;
+          if (message == "error") {
+            message = "Error: save failed.  Please save your content locally and reload this page.";
+          }
           $.unblockUI();
           self.showMessage("error", message);
         },

-- PaulMerchantJr

Michael - Is this okay for 2.1.3?

-- GeorgeClark - 15 Jan 2017

Fixed it somewhat differently without duplicating the logic and the error message.

-- MichaelDaum - 16 Jan 2017

Terrific, thanks!

-- PaulMerchantJr - 17 Jan 2017

smile

-- MichaelDaum - 17 Jan 2017
 

ItemTemplate edit

Summary NatEdit plugin leaves UI blocked after some save errors
ReportedBy PaulMerchantJr
Codebase 2.1.3 beta1, 2.1.2
SVN Range
AppliesTo Extension
Component NatEditPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:fb960a7d7e55
TargetRelease patch
ReleasedIn 2.1.3
CheckinsOnBranches Release02x01 master
trunkCheckins
masterCheckins distro:fb960a7d7e55
ItemBranchCheckins
Release02x01Checkins distro:fb960a7d7e55
Release02x00Checkins
Release01x01Checkins
Topic revision: r7 - 18 Feb 2017, GeorgeClark - This page was cached on 02 Mar 2017 - 11:51.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License