-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot set property WebSocket of #<Object> which has only a getter / Gradio App not working in NextJS #5583
Comments
Since this seems to to be an environment or framework specific issue, we will need a more complete reproduction. Could you put together a github repo with a default next app showing this problem? Preferably one that connects to a public HF space so we can run it. Thanks. |
Will close for now -- can reopen once we have a repro. |
not fixed? |
I'm currently working on a way to replicate the issue, by creating a new repo that doesn't use my company's code. Will share once complete. But it appears so far that fetching data from Hugging Face via Gradio generates this error when run inside a Next.js project. |
Do you have a dump of your system info? Is next running locally or deployed to vercel? If deployed, do you know if it is using the worker runtime or the lambda runtime? |
I also met this issue. running in my local env. sw_vers
ProductName: macOS
ProductVersion: 13.2.1
node -v
v18.14.2
npm show @gradio/client version
0.4.1 |
I'm running it locally on VSCode. Windows 10
|
I've replicated the issue at the following repo: https://github.com/TommeZ/gradio-fetch getTest().js makes a request to Hugging Face which returns the mentioned error, whereas it should be returning a string in the terminal. |
Thanks you! |
Found a similar issue here: vercel/next.js#41866 with a really simple fix |
@Jay2theWhy do you mean the fix: |
@JimmyLv I mean this PR that was merged for the fix: spacebudz/lucid#108. From my testing, this resolved my conflict with my gradio app and next.js. I also ran the unit tests on this change and all passed. |
@Jay2theWhy cool, I just saw your PR #5840 good job! 👍 |
Still having this exact issue with NextJS implemented with hugging face. |
I've just updated to the latest gradio/client via npm, and I'm receiving the same error still? Not sure if I follow what the fix was and the subsequent steps to take. |
We haven't released a new version of the client just yet, but will be soon (in the next day or so) |
Thanks for your support gentlemen. |
Just upgraded to v0.5.2 but still running into this problem, I'm pretty sure ========global.Websocket======== undefined undefined
TypeError: Cannot set property WebSocket of #<Object> which has only a getter Seems like the error might be due to trying to set a property on a frozen object or a non-extensible So my solution was to define let MyWebSocket
function api_factory(fetch_implementation, WebSocket_factory) {
...
async function client2(app_reference, options = { normalise_files: true }) {
if ((typeof window === "undefined" || !("WebSocket" in window)) && !globalThis.Websocket) {
const ws = await import("./wrapper-6f348d45.js");
NodeBlob = (await import("node:buffer")).Blob;
MyWebSocket = ws.WebSocket;
}
}
}
const { post_data, upload_files, client, handle_blob } = api_factory(
fetch,
(...args) => new MyWebSocket(...args)
); At the same time I realized that another solution is to customize a |
If it is undefined but can't be assigned then the client won't work without some other changes. I'll take a closer look at this as soon as I can. |
Yeah even on the newest version I am still getting
|
Any updates or workarounds on this? |
Any update guys? |
I also have the issue. Super annoying. Is there any version of node or nextjs where this isn't an issue? |
Why was this closed it is still not fixed |
I'm also getting the same issue. client version 0.10.1. Vanilla install of nextjs v14
Error
|
I also have the same issue. |
Sorry guys, finally had some time to take a second look at this and figured out why my previous PR wasn't working as intended: #5840 . For anyone curious, this commit was the culprit |
Closed by #8118! |
Describe the bug
I can't find anything that resolves my specific issue.
I'm trying to make a fetch request to my HuggingFace space via the Gradio app on my NextJS project, but I'm getting the following error:
The text was updated successfully, but these errors were encountered: