File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,27 +6,25 @@ const delay = (ms) => new Promise((result) => setTimeout(result, ms));
66async function getDefaultInterface ( ) {
77 const command =
88 "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'" ;
9- const result = await shell ( command ) ;
109
11- if ( result . stdout . length === 0 && result . stderr . length > 0 ) {
12- throw new Error (
13- 'There was an error getting the default interface:\n\n' + result . stderr
14- ) ;
15- } else if ( result . stdout . length === 0 ) {
16- // lets do one retry
17- // The GitHub Actions sometimes cannot find the interface
18- await delay ( 1000 ) ;
10+ // Retry a few times since GitHub Actions sometimes temporarily loses the default route
11+ for ( let attempt = 0 ; attempt < 3 ; attempt ++ ) {
1912 const result = await shell ( command ) ;
20- if ( result . stdout . length === 0 ) {
21- const result = await shell ( 'sudo ip route show' ) ;
13+ if ( result . stdout . length > 0 ) {
14+ return result . stdout ;
15+ }
16+ if ( result . stderr . length > 0 ) {
2217 throw new Error (
23- ` There was an error getting the default interface ${ result . stdout } `
18+ ' There was an error getting the default interface:\n\n' + result . stderr
2419 ) ;
2520 }
26- return result . stdout ;
21+ await delay ( 1000 ) ;
2722 }
2823
29- return result . stdout ;
24+ const result = await shell ( 'sudo ip route show' ) ;
25+ throw new Error (
26+ `There was an error getting the default interface ${ result . stdout } `
27+ ) ;
3028}
3129
3230async function moduleProbe ( ) {
You can’t perform that action at this time.
0 commit comments