File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ class Replicate {
129129 * @returns {Promise<object> } - Resolves with the output of running the model
130130 */
131131 async run ( ref , options , progress ) {
132- const { wait, ...data } = options ;
132+ const { wait, signal , ...data } = options ;
133133
134134 const identifier = ModelVersionIdentifier . parse ( ref ) ;
135135
@@ -153,8 +153,6 @@ class Replicate {
153153 progress ( prediction ) ;
154154 }
155155
156- const { signal } = options ;
157-
158156 prediction = await this . wait (
159157 prediction ,
160158 wait || { } ,
Original file line number Diff line number Diff line change @@ -1233,11 +1233,14 @@ describe("Replicate client", () => {
12331233 test ( "Aborts the operation when abort signal is invoked" , async ( ) => {
12341234 const controller = new AbortController ( ) ;
12351235 const { signal } = controller ;
1236+ let body : Record < string , unknown > | undefined ;
12361237
12371238 const scope = nock ( BASE_URL )
1238- . post ( "/predictions" , ( body ) => {
1239+ . post ( "/predictions" , ( _body ) => {
1240+ // Should not pass the signal object in the body.
1241+ body = _body ;
12391242 controller . abort ( ) ;
1240- return body ;
1243+ return _body ;
12411244 } )
12421245 . reply ( 201 , {
12431246 id : "ufawqhfynnddngldkgtslldrkq" ,
@@ -1263,7 +1266,10 @@ describe("Replicate client", () => {
12631266 }
12641267 ) ;
12651268
1269+ expect ( body ) . toBeDefined ( ) ;
1270+ expect ( body ?. [ "signal" ] ) . toBeUndefined ( ) ;
12661271 expect ( signal . aborted ) . toBe ( true ) ;
1272+ expect ( output ) . toBeUndefined ( ) ;
12671273
12681274 scope . done ( ) ;
12691275 } ) ;
You can’t perform that action at this time.
0 commit comments