You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the JS(TS) client, _resolve_config calls check_space_status and passes this.handle_space_success. In handle_space_success an error is thrown if this is not defined. This error will always occur whenever check_space_status is called because this.handle_space_success does not have this bound. To fix this, define this.handle_space_success = this.handle_space_success.bind(this) in the client constructor. This will prevent the error; however, it doesn't appear that status_callbacks will ever work correctly because they depend on being able to reach the space and if the space is paused or sleeping, it appears the _resolve_config will always fail.
A workaround is to create a subclass of Client that properly binds the handle_space_success function:
Then use this client instead of the gradio client.
Have you searched existing issues? 🔎
I have searched and found no existing issues
Reproduction
import{Client,SpaceStatus}from"@gradio/client";constapp=awaitClient.connect(spaceId,{hf_token: hfToken,status_callback: (space_status: SpaceStatus)=>console.log("Status updated: ",space_status),// This is an undocumented option that is apparently required if we have more outputs than inputswith_null_state: true,})
Pause the HF Space and run this code and you will see the error thrown when handle_space_success is called and this is not defined.
Screenshot
No response
Logs
The error thrown from the Client is `Error: Could not resolve app config. `
System Info
"@gradio/client": "^1.1.1",
Severity
I can work around it
The text was updated successfully, but these errors were encountered:
I think it is expected that a paused space will throw an error because a paused space may never restart (paused space have been manually stopped by the creator), and the client needs to be able to connect to the space to do anything. A sleeping space, however, should eventually resolve because the client should wake it up and then wait for it to move to running. Sleeping spaces have just been inactive for some time and wake up when a request is made.
Note that the error thrown when it can't connect to the space is a little misleading: TypeError: Cannot destructure property 'config' of 'undefined' as it is undefined.. This appears to be caused by this code in init:
this._resolve_config throws an error if it can't connect to the space, but the error isn't handled so then is called with an undefined value which fails to destructure. Should maybe do
Describe the bug
In the JS(TS) client,
_resolve_config
callscheck_space_status
and passesthis.handle_space_success
. Inhandle_space_success
an error is thrown ifthis
is not defined. This error will always occur whenevercheck_space_status
is called becausethis.handle_space_success
does not havethis
bound. To fix this, definethis.handle_space_success = this.handle_space_success.bind(this)
in the client constructor. This will prevent the error; however, it doesn't appear that status_callbacks will ever work correctly because they depend on being able to reach the space and if the space is paused or sleeping, it appears the _resolve_config will always fail.A workaround is to create a subclass of Client that properly binds the handle_space_success function:
Then use this client instead of the gradio client.
Have you searched existing issues? 🔎
Reproduction
Pause the HF Space and run this code and you will see the error thrown when
handle_space_success
is called and this is not defined.Screenshot
No response
Logs
The error thrown from the Client is `Error: Could not resolve app config. `
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: