@@ -46,7 +46,7 @@ class HttpTransport {
4646 return options ?. signal ?? AbortSignal . timeout ( this . opts . timeoutMs ) ;
4747 }
4848
49- async post < T = unknown > ( path : string , body : unknown , options ?: RequestOptions ) : Promise < T > {
49+ async post < T = unknown > ( path : string , body : unknown , options ?: RequestOptions ) : Promise < T | undefined > {
5050 const url = `${ this . opts . gatewayUrl } ${ path } ` ;
5151
5252 const response = await fetch ( url , {
@@ -63,7 +63,7 @@ class HttpTransport {
6363
6464 // 202 Accepted or 204 No Content - no body to parse
6565 if ( response . status === 202 || response . status === 204 ) {
66- return undefined as T ;
66+ return undefined ;
6767 }
6868
6969 return ( await response . json ( ) ) as T ;
@@ -106,17 +106,8 @@ class TemplatesNamespace {
106106 async create (
107107 req : TemplateCreateRequest ,
108108 options ?: RequestOptions
109- ) : Promise < { accepted : boolean } > {
110- try {
111- await this . http . post ( "/api/templates" , req , options ) ;
112- // If we get here without error, the request was accepted (202) or succeeded
113- return { accepted : true } ;
114- } catch ( error ) {
115- if ( error instanceof ComputeClientError && error . status === 202 ) {
116- return { accepted : true } ;
117- }
118- throw error ;
119- }
109+ ) : Promise < void > {
110+ await this . http . post ( "/api/templates" , req , options ) ;
120111 }
121112}
122113
@@ -127,7 +118,11 @@ class InstancesNamespace {
127118 req : InstanceCreateRequest ,
128119 options ?: RequestOptions
129120 ) : Promise < InstanceCreateResponse > {
130- return this . http . post < InstanceCreateResponse > ( "/api/instances" , req , options ) ;
121+ const result = await this . http . post < InstanceCreateResponse > ( "/api/instances" , req , options ) ;
122+ if ( ! result ) {
123+ throw new Error ( "Compute gateway returned no instance body" ) ;
124+ }
125+ return result ;
131126 }
132127
133128 async delete ( runnerId : string , options ?: RequestOptions ) : Promise < void > {
0 commit comments