-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
ReferenceError: EventSource is not defined
when API request in Node.js
#6352
Comments
I can run the code with simple tricks, but but it doesn't seem to be clean.
// npm i eventsource
import { client } from "@gradio/client";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
global.EventSource = require('eventsource');
const app = await client("gradio/hello_world");
const result = await app.predict("/predict", [
"John",
]);
console.log(result.data); Then, another error will be occured instead of the EventSource.
// before
eventSource = new EventSource(url);
// after
eventSource = new EventSource(url.toString()); Finally, I can get a output without the error. |
Hello, PS: Work around works fine for me as well I wish all of you a nice day ☀️ |
Also got the same issue with Node/Nuxt - without using a command. I had to install eventsource ("npm i eventsource") and use the work around. I also fixed the other call to EventSource Factory, line 1071:
|
we broke it, will release again early next week! |
fixed by #8252 |
Describe the bug
I am testing API request in Node.js with @gradio/client.
But,
ReferenceError: EventSource is not defined
is occured when I execute the code by the command.Have you searched existing issues? 🔎
Reproduction
"type": "module"
must be set inpackage.json
test.js
Then, execute
node test.js
in the commandScreenshot
No response
Logs
file:///C:/source/gradio_test/nodejs_client0.7.2/node_modules/@gradio/client/dist/index.js:733 eventSource = new EventSource(url); ^ ReferenceError: EventSource is not defined at file:///C:/source/gradio_test/nodejs_client0.7.2/node_modules/@gradio/client/dist/index.js:733:13 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Node.js v20.9.0
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: