File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,18 +22,29 @@ export const connectCommand = new commander.Command('connect')
2222 // We explicitly call exit because the sandbox is keeping the program alive.
2323 // We also don't want to call sandbox.close because that would disconnect other users from the edit session.
2424 process . exit ( 0 )
25- } catch ( err : any ) {
26- console . error ( err )
27- const message =
28- typeof err ?. message === 'string' ? err . message : String ( err )
29- if ( / u n k n o w n [ _ ] e r r o r / i. test ( message ) ) {
30- console . error (
31- 'Connection closed, it might be because the sandbox has reached the end of its lifecycle.'
32- )
33- }
34- process . exit ( 1 )
35- }
36- } )
25+ } catch ( err : any ) {
26+ console . error ( err )
27+ const message =
28+ typeof err ?. message === 'string' ? err . message : String ( err )
29+ if ( shouldShowLifecycleHint ( message ) ) {
30+ console . error (
31+ 'Connection closed, it might be because the sandbox has reached the end of its lifecycle.'
32+ )
33+ }
34+ process . exit ( 1 )
35+ }
36+ } )
37+
38+ function shouldShowLifecycleHint ( message : string ) : boolean {
39+ // Observed examples:
40+ // - "unknown_error"
41+ // - "Unknown error"
42+ // - "2: [unknown] terminated" (gRPC code 2 = UNKNOWN)
43+ return (
44+ / u n k n o w n [ _ ] e r r o r / i. test ( message ) ||
45+ ( / \[ u n k n o w n \] / i. test ( message ) && / \b t e r m i n a t e d \b / i. test ( message ) )
46+ )
47+ }
3748
3849async function connectToSandbox ( {
3950 apiKey,
You can’t perform that action at this time.
0 commit comments