fable 3.0.110 → 3.0.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -25,8 +25,21 @@ class FableServiceAnticipate extends libFableServiceBase
|
|
|
25
25
|
|
|
26
26
|
checkQueue()
|
|
27
27
|
{
|
|
28
|
+
// This could be combined with the last else if stanza but the logic for errors and non-errors would be blended and more complex to follow so keeping it unrolled.
|
|
29
|
+
if (this.lastError)
|
|
30
|
+
{
|
|
31
|
+
// If there are no operations left, and we have waiting functions, call them.
|
|
32
|
+
for (let i = 0; i < this.waitingFunctions.length; i++)
|
|
33
|
+
{
|
|
34
|
+
//this.log.trace('Calling waiting function.')
|
|
35
|
+
this.waitingFunctions[i](this.lastError);
|
|
36
|
+
}
|
|
37
|
+
// Reset our state
|
|
38
|
+
this.lastError = undefined;
|
|
39
|
+
this.waitingFunctions = [];
|
|
40
|
+
}
|
|
28
41
|
// This checks to see if we need to start any operations.
|
|
29
|
-
if (this.operationQueue.length > 0 && this.executingOperationCount < this.maxOperations)
|
|
42
|
+
else if (this.operationQueue.length > 0 && this.executingOperationCount < this.maxOperations)
|
|
30
43
|
{
|
|
31
44
|
let tmpOperation = this.operationQueue.shift();
|
|
32
45
|
this.executingOperationCount += 1;
|
|
@@ -72,7 +85,7 @@ class FableServiceAnticipate extends libFableServiceBase
|
|
|
72
85
|
throw new Error("Anticipation async callback called twice...");
|
|
73
86
|
}
|
|
74
87
|
tmpCallbackState.Called = true;
|
|
75
|
-
|
|
88
|
+
this.lastError = pError;
|
|
76
89
|
|
|
77
90
|
tmpCallbackState.OperationSet.executingOperationCount -= 1;
|
|
78
91
|
tmpCallbackState.OperationSet.completedOperationCount += 1;
|
package/test/Anticipate_tests.js
CHANGED
|
@@ -85,6 +85,60 @@ suite
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
|
+
test
|
|
89
|
+
(
|
|
90
|
+
'Error bailout',
|
|
91
|
+
function (fTestComplete)
|
|
92
|
+
{
|
|
93
|
+
let testFable = new libFable();
|
|
94
|
+
let tmpAnticipate = testFable.newAnticipate();
|
|
95
|
+
let tmpPostErrorMethodCalled = false;
|
|
96
|
+
tmpAnticipate.anticipate(function (fCallback)
|
|
97
|
+
{
|
|
98
|
+
testFable.log.info('Operation First test timeout entered...');
|
|
99
|
+
setTimeout(function ()
|
|
100
|
+
{
|
|
101
|
+
testFable.log.info(`Operation First test timeout done!`);
|
|
102
|
+
fCallback();
|
|
103
|
+
}, 500);
|
|
104
|
+
});
|
|
105
|
+
tmpAnticipate.anticipate(function (fCallback)
|
|
106
|
+
{
|
|
107
|
+
testFable.log.info('Operation Second test timeout entered...');
|
|
108
|
+
setTimeout(function ()
|
|
109
|
+
{
|
|
110
|
+
testFable.log.info(`Operation Second test timeout done!`);
|
|
111
|
+
fCallback();
|
|
112
|
+
}, 50);
|
|
113
|
+
});
|
|
114
|
+
tmpAnticipate.anticipate(function (fCallback)
|
|
115
|
+
{
|
|
116
|
+
testFable.log.info('Operation Second test timeout entered...');
|
|
117
|
+
setTimeout(function ()
|
|
118
|
+
{
|
|
119
|
+
testFable.log.info(`Operation Second test timeout done!`);
|
|
120
|
+
fCallback(new Error('Bail out or else!'));
|
|
121
|
+
}, 50);
|
|
122
|
+
});
|
|
123
|
+
tmpAnticipate.anticipate(function (fCallback)
|
|
124
|
+
{
|
|
125
|
+
testFable.log.info('Operation Third test timeout entered...');
|
|
126
|
+
setTimeout(function ()
|
|
127
|
+
{
|
|
128
|
+
tmpPostErrorMethodCalled = true;
|
|
129
|
+
testFable.log.info(`Operation Third test timeout done!`);
|
|
130
|
+
fCallback();
|
|
131
|
+
}, 50);
|
|
132
|
+
});
|
|
133
|
+
tmpAnticipate.wait(function (pError)
|
|
134
|
+
{
|
|
135
|
+
Expect(pError).to.be.an('error');
|
|
136
|
+
Expect(tmpPostErrorMethodCalled).to.equal(false);
|
|
137
|
+
testFable.log.info(`Wait 1 completed: ${pError}`)
|
|
138
|
+
return fTestComplete();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
);
|
|
88
142
|
test
|
|
89
143
|
(
|
|
90
144
|
'Huge call stack',
|