File tree Expand file tree Collapse file tree 5 files changed +389
-654
lines changed Expand file tree Collapse file tree 5 files changed +389
-654
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,7 @@ export class InternalPingType implements CommonPingData {
114114 }
115115
116116 /// TESTING ///
117- // TODO
118- // Does this need to go away?
119- testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : void {
117+ async testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : Promise < void > {
120118 if ( testOnlyCheck ( "testBeforeNextSubmit" , LOG_TAG ) ) {
121119 if ( this . testCallback ) {
122120 log (
@@ -127,7 +125,11 @@ export class InternalPingType implements CommonPingData {
127125 return ;
128126 }
129127
130- this . testCallback = callbackFn ;
128+ return new Promise ( ( resolve , reject ) => {
129+ this . resolveTestPromiseFunction = resolve ;
130+ this . rejectTestPromiseFunction = reject ;
131+ this . testCallback = callbackFn ;
132+ } ) ;
131133 }
132134 }
133135}
@@ -161,8 +163,6 @@ export default class {
161163 this . #inner. submit ( reason ) ;
162164 }
163165
164- // TODO
165- // Does this need to go away?
166166 /**
167167 * Test-only API
168168 *
@@ -173,7 +173,7 @@ export default class {
173173 * @returns A `Promise` resolved when the ping is collected and the validation function
174174 * is executed.
175175 */
176- testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : void {
176+ testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : Promise < void > {
177177 return this . #inner. testBeforeNextSubmit ( callbackFn ) ;
178178 }
179179}
Original file line number Diff line number Diff line change @@ -130,28 +130,35 @@ class PingUploadWorker {
130130 getUploadTask : ( ) => UploadTask ,
131131 processUploadResponse : ( ping : QueuedPing , result : UploadResult ) => void
132132 ) : void {
133- try {
134- const task = getUploadTask ( ) ;
135- switch ( task . type ) {
136- case UploadTaskTypes . Upload :
137- if ( this . isBlocking ) {
138- return ;
133+ while ( true ) {
134+ try {
135+ const task = getUploadTask ( ) ;
136+ switch ( task . type ) {
137+ case UploadTaskTypes . Upload : {
138+ if ( this . isBlocking ) {
139+ return ;
140+ }
141+
142+ this . attemptPingUpload ( task . ping )
143+ . then ( ( result ) => {
144+ processUploadResponse ( task . ping , result ) ;
145+ } )
146+ . catch ( ( error ) => {
147+ console . log ( error ) ;
148+ } ) ;
149+ continue ;
139150 }
140151
141- this . attemptPingUpload ( task . ping )
142- . then ( ( result ) => {
143- processUploadResponse ( task . ping , result ) ;
144- } )
145- . catch ( ( error ) => {
146- console . log ( error ) ;
147- } ) ;
152+ case UploadTaskTypes . Done :
153+ return ;
154+ }
155+ } catch ( error ) {
156+ log (
157+ PING_UPLOAD_WORKER_LOG_TAG ,
158+ [ "IMPOSSIBLE: Something went wrong while processing ping upload tasks." , error ] ,
159+ LoggingLevel . Error
160+ ) ;
148161 }
149- } catch ( error ) {
150- log (
151- PING_UPLOAD_WORKER_LOG_TAG ,
152- [ "IMPOSSIBLE: Something went wrong while processing ping upload tasks." , error ] ,
153- LoggingLevel . Error
154- ) ;
155162 }
156163 }
157164
You can’t perform that action at this time.
0 commit comments