@@ -146,28 +146,34 @@ export class ExampleShell {
146146 let buffer = '' ;
147147 const expoUrlRegex = / ( e x p : \/ \/ [ ^ \s ] + ) / ;
148148
149- while ( true ) {
150- const { value, done } = await reader . read ( ) ;
149+ try {
150+ while ( true ) {
151+ const { value, done } = await reader . read ( ) ;
151152
152- if ( done ) {
153- break ;
154- }
153+ if ( done ) {
154+ break ;
155+ }
155156
156- buffer += value || '' ;
157+ buffer += value || '' ;
157158
158- const expoUrlMatch = buffer . match ( expoUrlRegex ) ;
159+ const expoUrlMatch = buffer . match ( expoUrlRegex ) ;
159160
160- if ( expoUrlMatch ) {
161- const cleanUrl = expoUrlMatch [ 1 ]
162- . replace ( / [ \u001b \u009b ] [ [ ( ) # ; ? ] * (?: [ 0 - 9 ] { 1 , 4 } (?: ; [ 0 - 9 ] { 0 , 4 } ) * ) ? [ 0 - 9 A - O R Z c f - n q r y = > < ] / g, '' )
163- . replace ( / [ ^ \x20 - \x7E ] + $ / g, '' ) ;
164- expoUrlAtom . set ( cleanUrl ) ;
165- buffer = buffer . slice ( buffer . indexOf ( expoUrlMatch [ 1 ] ) + expoUrlMatch [ 1 ] . length ) ;
166- }
161+ if ( expoUrlMatch ) {
162+ const cleanUrl = expoUrlMatch [ 1 ]
163+ . replace ( / [ \u001b \u009b ] [ [ ( ) # ; ? ] * (?: [ 0 - 9 ] { 1 , 4 } (?: ; [ 0 - 9 ] { 0 , 4 } ) * ) ? [ 0 - 9 A - O R Z c f - n q r y = > < ] / g, '' )
164+ . replace ( / [ ^ \x20 - \x7E ] + $ / g, '' ) ;
165+ expoUrlAtom . set ( cleanUrl ) ;
166+ buffer = buffer . slice ( buffer . indexOf ( expoUrlMatch [ 1 ] ) + expoUrlMatch [ 1 ] . length ) ;
167+ }
167168
168- if ( buffer . length > 2048 ) {
169- buffer = buffer . slice ( - 2048 ) ;
169+ if ( buffer . length > 2048 ) {
170+ buffer = buffer . slice ( - 2048 ) ;
171+ }
170172 }
173+ } catch ( error ) {
174+ console . error ( 'Error in Expo URL watcher:' , error ) ;
175+ } finally {
176+ reader . releaseLock ( ) ;
171177 }
172178 }
173179
0 commit comments