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].

stephan 2021-10-08 17:42 trunk
Commit 49e3bf7b1324afae10c34d7f52bd623687dae81949445b8b02f9783f73ce1578
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -578,12 +578,16 @@
578578
fetchType = this.FetchType.FillGap;
579579
}
580580
}
581581
//console.debug("fetchChunk(",fetchType,")",up);
582582
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
+ }
585589
};
586590
Diff.fetchArtifactChunk(fOpt);
587591
return this;
588592
}
589593
};
590594
--- 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
--- src/fossil.fetch.js
+++ src/fossil.fetch.js
@@ -27,13 +27,18 @@
2727
"this", noting that this call may have amended the options object
2828
with state other than what the caller provided.
2929
3030
- onerror: callback(Error object) (default = output error message
3131
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.
3540
3641
- method: 'POST' | 'GET' (default = 'GET'). CASE SENSITIVE!
3742
3843
- payload: anything acceptable by XHR2.send(ARG) (DOMString,
3944
Document, FormData, Blob, File, ArrayBuffer), or a plain object or
4045
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button