MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / post

Method post

ui/media/js/engine.js:889–919  ·  view source on GitHub ↗

Send current task to server. * @param {*} [timeout=-1] Optional timeout value in ms * @returns the response from the render request. * @memberof Task

(timeout = -1)

Source from the content-addressed store, hash-verified

887 * @memberof Task
888 */
889 async post(timeout = -1) {
890 performance.mark("make-render-request")
891 if (performance.getEntriesByName("click-makeImage", "mark").length > 0) {
892 performance.measure("diff", "click-makeImage", "make-render-request")
893 console.log(
894 "delay between clicking and making the server request:",
895 performance.getEntriesByName("diff", "measure")[0].duration + " ms"
896 )
897 }
898
899 let jsonResponse = await super.post("/render", timeout)
900 if (typeof jsonResponse?.task !== "number") {
901 console.warn("Endpoint error response: ", jsonResponse)
902 const event = Object.assign({ task: this }, jsonResponse)
903 await eventSource.fireEvent(EVENT_UNEXPECTED_RESPONSE, event)
904 if ("continueWith" in event) {
905 jsonResponse = await Promise.resolve(event.continueWith)
906 }
907 if (typeof jsonResponse?.task !== "number") {
908 const err = new Error(jsonResponse?.detail || "Endpoint response does not contains a task ID.")
909 this.abort(err)
910 throw err
911 }
912 }
913 this._setId(jsonResponse.task)
914 if (jsonResponse.stream) {
915 this.streamUrl = jsonResponse.stream
916 }
917 this._setStatus(TaskStatus.waiting)
918 return jsonResponse
919 }
920
921 enqueue(progressCallback) {
922 return Task.enqueueNew(this, RenderTask, progressCallback)

Callers 1

startMethod · 0.95

Calls 5

fireEventMethod · 0.80
abortMethod · 0.80
_setIdMethod · 0.80
_setStatusMethod · 0.80
postMethod · 0.45

Tested by

no test coverage detected