File tree 2 files changed +32
-14
lines changed
2 files changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -46,23 +46,32 @@ export async function waitForDeviceToComeOnline(
46
46
47
47
return new Promise < boolean > ( ( resolve , reject ) => {
48
48
const flashTimeout = setTimeout ( ( ) => {
49
- stream . abort ( )
50
- stream . stopIdleTimeout ( )
49
+ try {
50
+ stream . abort ( )
51
+ stream . stopIdleTimeout ( )
52
+ } catch ( cleanupError ) {
53
+ core . warning ( `Error during stream cleanup: ${ cleanupError } ` )
54
+ }
51
55
reject ( new Error ( 'timed out waiting for device to come back online' ) )
52
56
} , timeoutMs )
53
57
54
58
core . info ( 'waiting for device to come online' )
55
- stream . on ( 'event' , ( event : { data : string } ) => {
59
+
60
+ stream . on ( 'event' , async ( event : { data : string } ) => {
56
61
try {
57
62
if ( event . data === 'online' ) {
58
63
core . info ( 'device is online' )
59
64
clearTimeout ( flashTimeout )
60
- stream . abort ( )
61
- stream . stopIdleTimeout ( )
65
+ try {
66
+ stream . abort ( )
67
+ stream . stopIdleTimeout ( )
68
+ } catch ( cleanupError ) {
69
+ core . warning ( `Error during stream cleanup: ${ cleanupError } ` )
70
+ }
62
71
resolve ( true )
63
72
}
64
73
} catch ( error ) {
65
- if ( error instanceof Error ) core . debug ( error . message )
74
+ core . warning ( `Error in stream event handler: ${ ( error as Error ) . message } ` )
66
75
reject ( new Error ( 'error waiting for device to come online' ) )
67
76
}
68
77
} )
You can’t perform that action at this time.
0 commit comments