fable 3.0.109 → 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/debug/Harness.js +1 -1
- package/dist/fable.compatible.js +5 -5
- package/dist/fable.compatible.min.js +2 -2
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +5 -5
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/services/Fable-Service-Anticipate.js +15 -2
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-StringParser.js +4 -4
- package/test/Anticipate_tests.js +54 -0
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;
|
|
@@ -113,7 +113,7 @@ class StringParser
|
|
|
113
113
|
}
|
|
114
114
|
else
|
|
115
115
|
{
|
|
116
|
-
|
|
116
|
+
this.fable.log.info(`MetaTemplate: The pattern ${pParserState.Pattern.PatternStartString} is asynchronous and cannot be used in a synchronous parser.`);
|
|
117
117
|
return this.resetOutputBuffer(pParserState);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -150,7 +150,7 @@ class StringParser
|
|
|
150
150
|
{
|
|
151
151
|
if (pParserState.Pattern.isAsync && !pParserState.Pattern.isBoth)
|
|
152
152
|
{
|
|
153
|
-
|
|
153
|
+
this.fable.log.info(`MetaTemplate: The pattern ${pParserState.Pattern.PatternStartString} is asynchronous and cannot be used in a synchronous parser.`);
|
|
154
154
|
this.resetOutputBuffer(pParserState);
|
|
155
155
|
}
|
|
156
156
|
else
|
|
@@ -201,7 +201,7 @@ class StringParser
|
|
|
201
201
|
{
|
|
202
202
|
if (pError)
|
|
203
203
|
{
|
|
204
|
-
|
|
204
|
+
this.fable.log.info(`Precedent ERROR: Async template error happened parsing ${pParserState.Pattern.PatternStart} ... ${pParserState.Pattern.PatternEnd}: ${pError}`);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
pParserState.OutputBuffer = pAsyncOutput;
|
|
@@ -217,7 +217,7 @@ class StringParser
|
|
|
217
217
|
{
|
|
218
218
|
if (pError)
|
|
219
219
|
{
|
|
220
|
-
|
|
220
|
+
this.fable.log.info(`Precedent ERROR: Async template error happened parsing ${pParserState.Pattern.PatternStart} ... ${pParserState.Pattern.PatternEnd}: ${pError}`);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
pParserState.OutputBuffer = pAsyncOutput;
|
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',
|