@@ -137,7 +137,8 @@ export async function startWorkspaceIfStoppedOrFailed(
137
137
}
138
138
139
139
return new Promise ( ( resolve , reject ) => {
140
- const startProcess = spawn ( binPath , [ "start" , "--yes" , workspace . owner_name + "/" + workspace . name ] )
140
+ const startArgs = [ "start" , "--yes" , workspace . owner_name + "/" + workspace . name ]
141
+ const startProcess = spawn ( binPath , startArgs )
141
142
142
143
startProcess . stdout . on ( "data" , ( data : Buffer ) => {
143
144
data
@@ -150,13 +151,15 @@ export async function startWorkspaceIfStoppedOrFailed(
150
151
} )
151
152
} )
152
153
154
+ let capturedStderr = ""
153
155
startProcess . stderr . on ( "data" , ( data : Buffer ) => {
154
156
data
155
157
. toString ( )
156
158
. split ( / \r * \n / )
157
159
. forEach ( ( line : string ) => {
158
160
if ( line !== "" ) {
159
161
writeEmitter . fire ( line . toString ( ) + "\r\n" )
162
+ capturedStderr += line . toString ( ) + "\n"
160
163
}
161
164
} )
162
165
} )
@@ -165,7 +168,11 @@ export async function startWorkspaceIfStoppedOrFailed(
165
168
if ( code === 0 ) {
166
169
resolve ( restClient . getWorkspace ( workspace . id ) )
167
170
} else {
168
- reject ( new Error ( `"coder start" process exited with code ${ code } ` ) )
171
+ let errorText = `"${ startArgs . join ( " " ) } " exited with code ${ code } `
172
+ if ( capturedStderr !== "" ) {
173
+ errorText += `: ${ capturedStderr } `
174
+ }
175
+ reject ( new Error ( errorText ) )
169
176
}
170
177
} )
171
178
} )
0 commit comments