@@ -215,6 +215,20 @@ export class ComfyApi extends EventTarget {
215215
216216 reportedUnknownMessageTypes = new Set < string > ( )
217217
218+ /**
219+ * The auth token for the comfy org account if the user is logged in.
220+ * This is only used for {@link queuePrompt} now. It is not directly
221+ * passed as parameter to the function because some custom nodes are hijacking
222+ * {@link queuePrompt} improperly, which causes extra parameters to be lost
223+ * in the function call chain.
224+ *
225+ * Ref: https://cs.comfy.org/search?q=context:global+%22api.queuePrompt+%3D%22&patternType=keyword&sm=0
226+ *
227+ * TODO: Move this field to parameter of {@link queuePrompt} once all
228+ * custom nodes are patched.
229+ */
230+ authToken ?: string
231+
218232 constructor ( ) {
219233 super ( )
220234 this . user = ''
@@ -517,21 +531,19 @@ export class ComfyApi extends EventTarget {
517531 * Queues a prompt to be executed
518532 * @param {number } number The index at which to queue the prompt, passing -1 will insert the prompt at the front of the queue
519533 * @param {object } prompt The prompt data to queue
520- * @param {string } authToken The auth token for the comfy org account if the user is logged in
521534 * @throws {PromptExecutionError } If the prompt fails to execute
522535 */
523536 async queuePrompt (
524537 number : number ,
525- data : { output : ComfyApiWorkflow ; workflow : ComfyWorkflowJSON } ,
526- authToken ?: string
538+ data : { output : ComfyApiWorkflow ; workflow : ComfyWorkflowJSON }
527539 ) : Promise < PromptResponse > {
528540 const { output : prompt , workflow } = data
529541
530542 const body : QueuePromptRequestBody = {
531543 client_id : this . clientId ?? '' , // TODO: Unify clientId access
532544 prompt,
533545 extra_data : {
534- auth_token_comfy_org : authToken ,
546+ auth_token_comfy_org : this . authToken ,
535547 extra_pnginfo : { workflow }
536548 }
537549 }
0 commit comments