File tree 2 files changed +10
-0
lines changed
2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change
1
+ export const delay = ( ms : number ) : Promise < void > =>
2
+ new Promise ( ( res ) => {
3
+ setTimeout ( res , ms )
4
+ } )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
17
17
UploadResponse ,
18
18
} from "api/typesGenerated"
19
19
import { displayError } from "components/GlobalSnackbar/utils"
20
+ import { delay } from "util/delay"
20
21
import { assign , createMachine } from "xstate"
21
22
22
23
// for creating a new template:
@@ -345,6 +346,11 @@ export const createTemplateMachine =
345
346
while ( [ "pending" , "running" ] . includes ( status ) ) {
346
347
version = await getTemplateVersion ( version . id )
347
348
status = version . job . status
349
+ // Delay the verification in two seconds to not overload the server
350
+ // with too many requests Maybe at some point we could have a
351
+ // websocket for template version Also, preferred doing this way to
352
+ // avoid a new state since we don't need to reflect it on the UI
353
+ await delay ( 2_000 )
348
354
}
349
355
return version
350
356
} ,
You can’t perform that action at this time.
0 commit comments