@@ -96,14 +96,13 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
96
96
} ;
97
97
98
98
// When we'll finish all the current job, we'll call finish
99
- // resolveQueuedJob
100
- let resolveQueuedDevice ;
99
+ let resolveQueuedJob ;
101
100
102
101
// Queue of linked Promises that wait after each other
103
102
// Blocking any future job on this device
104
103
deviceQueues [ deviceId ] = {
105
104
job : new Promise ( resolve => {
106
- resolveQueuedDevice = resolve ;
105
+ resolveQueuedJob = resolve ;
107
106
} ) ,
108
107
id : jobId ,
109
108
} ;
@@ -116,7 +115,7 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
116
115
if ( unsubscribed ) {
117
116
tracer . trace ( "Unsubscribed (1) while processing job" ) ;
118
117
// It was unsubscribed prematurely
119
- return finalize ( transport , [ resolveQueuedDevice ] ) ;
118
+ return finalize ( transport , [ resolveQueuedJob ] ) ;
120
119
}
121
120
122
121
if ( needsCleanup [ identifyTransport ( transport ) ] ) {
@@ -130,7 +129,7 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
130
129
// This catch is here only for errors that might happen at open or at clean up of the transport before doing the job
131
130
const onErrorDuringTransportSetup = ( error : unknown ) => {
132
131
tracer . trace ( "Error while setting up a transport: " , { error } ) ;
133
- resolveQueuedDevice ( ) ;
132
+ resolveQueuedJob ( ) ;
134
133
if ( error instanceof BluetoothRequired ) throw error ;
135
134
if ( error instanceof TransportWebUSBGestureRequired ) throw error ;
136
135
if ( error instanceof TransportInterfaceNotAvailable ) throw error ;
@@ -204,15 +203,15 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
204
203
if ( unsubscribed ) {
205
204
tracer . trace ( "Unsubscribed (2) while processing job" ) ;
206
205
// It was unsubscribed prematurely
207
- return finalize ( transportRef . current , [ resolveQueuedDevice ] ) ;
206
+ return finalize ( transportRef . current , [ resolveQueuedJob ] ) ;
208
207
}
209
208
210
209
sub = job ( { transportRef } )
211
210
. pipe (
212
211
catchError ( error => initialErrorRemapping ( error , tracer . getContext ( ) ) ) ,
213
212
catchError ( errorRemapping ) , // close the transport and clean up everything
214
213
transportFinally ( ( ) => {
215
- return finalize ( transportRef . current , [ resolveQueuedDevice ] ) ;
214
+ return finalize ( transportRef . current , [ resolveQueuedJob ] ) ;
216
215
} ) ,
217
216
)
218
217
. subscribe ( subscriber ) ;
0 commit comments