Fossil SCM
Documented fossil.fetch()'s behavior of onerror() being called if onload() throws. Added a safety net in the diff context loader to handle a corner case null dereference when an exception in onload() triggers onerror() after the context loader's DOM elements have been destroyed. [forum:7bc8301eb191cf6d|Forum post 7bc8301eb191cf6d].
Commit
49e3bf7b1324afae10c34d7f52bd623687dae81949445b8b02f9783f73ce1578
Parent
aad4b78936f1543…
2 files changed
+6
-2
+8
-3
+6
-2
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -578,12 +578,16 @@ | ||
| 578 | 578 | fetchType = this.FetchType.FillGap; |
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | //console.debug("fetchChunk(",fetchType,")",up); |
| 582 | 582 | fOpt.onerror = function(err){ |
| 583 | - self.msg(true,err.message); | |
| 584 | - self.$fetchQueue.length = 0; | |
| 583 | + if(self.e/*guard against a late-stage onerror() call*/){ | |
| 584 | + self.msg(true,err.message); | |
| 585 | + self.$fetchQueue.length = 0; | |
| 586 | + }else{ | |
| 587 | + Diff.config.chunkFetch.onerror.call(this,e); | |
| 588 | + } | |
| 585 | 589 | }; |
| 586 | 590 | Diff.fetchArtifactChunk(fOpt); |
| 587 | 591 | return this; |
| 588 | 592 | } |
| 589 | 593 | }; |
| 590 | 594 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -578,12 +578,16 @@ | |
| 578 | fetchType = this.FetchType.FillGap; |
| 579 | } |
| 580 | } |
| 581 | //console.debug("fetchChunk(",fetchType,")",up); |
| 582 | fOpt.onerror = function(err){ |
| 583 | self.msg(true,err.message); |
| 584 | self.$fetchQueue.length = 0; |
| 585 | }; |
| 586 | Diff.fetchArtifactChunk(fOpt); |
| 587 | return this; |
| 588 | } |
| 589 | }; |
| 590 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -578,12 +578,16 @@ | |
| 578 | fetchType = this.FetchType.FillGap; |
| 579 | } |
| 580 | } |
| 581 | //console.debug("fetchChunk(",fetchType,")",up); |
| 582 | fOpt.onerror = function(err){ |
| 583 | if(self.e/*guard against a late-stage onerror() call*/){ |
| 584 | self.msg(true,err.message); |
| 585 | self.$fetchQueue.length = 0; |
| 586 | }else{ |
| 587 | Diff.config.chunkFetch.onerror.call(this,e); |
| 588 | } |
| 589 | }; |
| 590 | Diff.fetchArtifactChunk(fOpt); |
| 591 | return this; |
| 592 | } |
| 593 | }; |
| 594 |
+8
-3
| --- src/fossil.fetch.js | ||
| +++ src/fossil.fetch.js | ||
| @@ -27,13 +27,18 @@ | ||
| 27 | 27 | "this", noting that this call may have amended the options object |
| 28 | 28 | with state other than what the caller provided. |
| 29 | 29 | |
| 30 | 30 | - onerror: callback(Error object) (default = output error message |
| 31 | 31 | to console.error() and fossil.error()). Triggered if the request |
| 32 | - generates any response other than HTTP 200 or suffers a connection | |
| 33 | - error or timeout while awaiting a response. In the context of the | |
| 34 | - callback, the options object is "this". | |
| 32 | + generates any response other than HTTP 200, suffers a connection | |
| 33 | + error or timeout while awaiting a response, or if the onload() | |
| 34 | + handler throws an exception. In the context of the callback, the | |
| 35 | + options object is "this". Note that this function is intended to be | |
| 36 | + used solely for error reporting, not error recovery. Because | |
| 37 | + onerror() may be called if onload() throws, it is up to the caller | |
| 38 | + to ensure that their onerror() callback references only state which | |
| 39 | + is valid in such a case. | |
| 35 | 40 | |
| 36 | 41 | - method: 'POST' | 'GET' (default = 'GET'). CASE SENSITIVE! |
| 37 | 42 | |
| 38 | 43 | - payload: anything acceptable by XHR2.send(ARG) (DOMString, |
| 39 | 44 | Document, FormData, Blob, File, ArrayBuffer), or a plain object or |
| 40 | 45 |
| --- src/fossil.fetch.js | |
| +++ src/fossil.fetch.js | |
| @@ -27,13 +27,18 @@ | |
| 27 | "this", noting that this call may have amended the options object |
| 28 | with state other than what the caller provided. |
| 29 | |
| 30 | - onerror: callback(Error object) (default = output error message |
| 31 | to console.error() and fossil.error()). Triggered if the request |
| 32 | generates any response other than HTTP 200 or suffers a connection |
| 33 | error or timeout while awaiting a response. In the context of the |
| 34 | callback, the options object is "this". |
| 35 | |
| 36 | - method: 'POST' | 'GET' (default = 'GET'). CASE SENSITIVE! |
| 37 | |
| 38 | - payload: anything acceptable by XHR2.send(ARG) (DOMString, |
| 39 | Document, FormData, Blob, File, ArrayBuffer), or a plain object or |
| 40 |
| --- src/fossil.fetch.js | |
| +++ src/fossil.fetch.js | |
| @@ -27,13 +27,18 @@ | |
| 27 | "this", noting that this call may have amended the options object |
| 28 | with state other than what the caller provided. |
| 29 | |
| 30 | - onerror: callback(Error object) (default = output error message |
| 31 | to console.error() and fossil.error()). Triggered if the request |
| 32 | generates any response other than HTTP 200, suffers a connection |
| 33 | error or timeout while awaiting a response, or if the onload() |
| 34 | handler throws an exception. In the context of the callback, the |
| 35 | options object is "this". Note that this function is intended to be |
| 36 | used solely for error reporting, not error recovery. Because |
| 37 | onerror() may be called if onload() throws, it is up to the caller |
| 38 | to ensure that their onerror() callback references only state which |
| 39 | is valid in such a case. |
| 40 | |
| 41 | - method: 'POST' | 'GET' (default = 'GET'). CASE SENSITIVE! |
| 42 | |
| 43 | - payload: anything acceptable by XHR2.send(ARG) (DOMString, |
| 44 | Document, FormData, Blob, File, ArrayBuffer), or a plain object or |
| 45 |