MCPcopy
hub / github.com/erictik/midjourney-api / cancel

Function cancel

src/gradio/client.ts:599–635  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

597 }
598
599 async function cancel() {
600 const _status: Status = {
601 stage: "complete",
602 queue: false,
603 time: new Date(),
604 };
605 complete = _status;
606 fire_event({
607 ..._status,
608 type: "status",
609 endpoint: _endpoint,
610 fn_index: fn_index,
611 });
612
613 if (websocket && websocket.readyState === 0) {
614 websocket.addEventListener("open", () => {
615 websocket.close();
616 });
617 } else {
618 websocket.close();
619 }
620
621 try {
622 await fetch_implementation(
623 `${http_protocol}//${host + config.path}/reset`,
624 {
625 headers: { "Content-Type": "application/json" },
626 method: "POST",
627 body: JSON.stringify({ fn_index, session_hash }),
628 }
629 );
630 } catch (e) {
631 console.warn(
632 "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
633 );
634 }
635 }
636
637 function destroy() {
638 for (const event_type in listener_map) {

Callers

nothing calls this directly

Calls 2

fire_eventFunction · 0.85
closeMethod · 0.80

Tested by

no test coverage detected