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 @@ -108,9 +108,7 @@ export class InternalPingType implements CommonPingData {
108108 }
109109
110110 /// TESTING ///
111- // TODO
112- // Does this need to go away?
113- testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : void {
111+ async testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : Promise < void > {
114112 if ( testOnlyCheck ( "testBeforeNextSubmit" , LOG_TAG ) ) {
115113 if ( this . testCallback ) {
116114 log (
@@ -121,7 +119,11 @@ export class InternalPingType implements CommonPingData {
121119 return ;
122120 }
123121
124- this . testCallback = callbackFn ;
122+ return new Promise ( ( resolve , reject ) => {
123+ this . resolveTestPromiseFunction = resolve ;
124+ this . rejectTestPromiseFunction = reject ;
125+ this . testCallback = callbackFn ;
126+ } ) ;
125127 }
126128 }
127129}
@@ -155,8 +157,6 @@ export default class {
155157 this . #inner. submit ( reason ) ;
156158 }
157159
158- // TODO
159- // Does this need to go away?
160160 /**
161161 * Test-only API
162162 *
@@ -167,7 +167,7 @@ export default class {
167167 * @returns A `Promise` resolved when the ping is collected and the validation function
168168 * is executed.
169169 */
170- testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : void {
170+ testBeforeNextSubmit ( callbackFn : ValidatorFunction ) : Promise < void > {
171171 return this . #inner. testBeforeNextSubmit ( callbackFn ) ;
172172 }
173173}
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