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
Add eventsource polyfill for Node.js and browser environments #8118
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/d3c2e57646ef2bf9576c34cb7ed232ced11c00cf/gradio-4.28.3-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@d3c2e57646ef2bf9576c34cb7ed232ced11c00cf#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to run these test in node as well. We can doo this by creating a new script:
"pnpm:test:client:node": "vitest client/js -c path/to/config --mode=test_node"
Then in the vite.config.ts
check the mode
is test_node
and set the test.environment
to "node"
. We would also need to check anything that is currently checking for just mode == "test"
and also catch the new node-test
.
@pngwn good thinking! i've added that now i'm not sure if there's anything relevant that's checking for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment but looks great. Thanks for sorting this one out @hannahblair! This will be a huge boost to quality!
…adio into client-eventsource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for ironing out the kinks with this one @hannahblair! And sorry for the back and forth!
* add msw setup and initialisation tests * add changeset * add eventsource polyfill for node and browser envs * add changeset * add changeset * config tweak * types * update eventsource usage * add changeset * add walk_and_store_blobs improvements and add tests * add changeset * api_info tests * add direct space URL link tests * fix tests * add view_api tests * add post_message test * tweak * add spaces tests * jwt and protocol tests * add post_data tests * test tweaks * dynamically import eventsource * revet eventsource imports * add node test * lockfile * add client test in root pkg file * lcokfile * remove eventsource from js/app * add changeset * remove ts ignore * move eventsource polyfill to eventsource factory * add changeset * tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Description
Replaces the Web API
eventsource
with eventsource to support Node.js environments. Also addresseswindow is not defined
errors in Node.js.To test, run the following in a node environment:
Closes: #6352
Closes: #7103
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh