FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

requests not working in Firefox · Issue #22 · koenvo/pyodide-http · GitHub

Repository navigation

requests not working in Firefox #22

Closed

Description

I've been trying to get the basic example to work in Jupyterlite, just changing micropip to instead use the %pip magic:

%pip install -q pyodide-http requests

import pyodide_http
pyodide_http.patch_all()  # Patch all libraries

import requests
response = requests.get('http://raw.githubusercontent.com/statsbomb/open-data/master/data/lineups/15946.json')

The cells run without errors, but the response object has a status code of 0, and response.content is empty. Am I missing something?

The result is the same running locally using jupyter lite serve, and on GitHub Pages.

Activity

  1. koenvo commented on Dec 14, 2022

    Owner

    Hmm there seems to be an issue with redirects. Can you try with https:// instead of http:// ?

  2. wragge commented on Dec 14, 2022

    Author

    That didn't seem to make any difference, but I had a look in the browser console and saw this:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.githubusercontent.com/statsbomb/open-data/master/data/lineups/15946.json. (Reason: CORS request did not succeed). Status code: (null).
    
    Failed to load ‘https://raw.githubusercontent.com/statsbomb/open-data/master/data/lineups/15946.json’. A ServiceWorker passed a promise to FetchEvent.respondWith() that rejected with ‘TypeError: NetworkError when attempting to fetch resource.’. 
    
  3. jtpio commented on Jan 3, 2023

    Also seeing something similar (status code 0) when trying out the following code snippet in jupyterlite/jupyterlite#940:

    %pip install seaborn
    import pyodide_http
    pyodide_http.patch_all()
    
    import seaborn as sns
    
    # Load an example dataset
    tips = sns.load_dataset("tips")

  4. koenvo commented on Jan 3, 2023

    Owner

    Thanks for the report!

    What browser did you use? I'm getting a JsException: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://github.com/mwaskom/seaborn-data'. error in Chrome on MacOS.

  5. jtpio commented on Jan 4, 2023

    It was with Firefox 108 with the following error:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://github.com/mwaskom/seaborn-data. (Reason: CORS request did not succeed). Status code: (null
    
  6. dazzag24 commented on Mar 30, 2023

    Seeing the same here:

    console output:

    Firefox 111.0.1 (64-bit)

  7. rth commented on Mar 30, 2023

    Contributor

    This might be an issue with the Pyodide FFI pyodide/pyodide#1653 where the exception isn't passed properly

  8. koenvo commented on Mar 30, 2023

    Owner

    Seeing the same here:

    console output:

    Firefox 111.0.1 (64-bit)

    Just installed Firefox and I do get the same error as you get. When I do a manual request using

    from js import XMLHttpRequest
    xhr = XMLHttpRequest.new()
    url = "https://raw.githubusercontent.com/statsbomb/open-data/master/data/lineups/15946.json"
    xhr.overrideMimeType("text/plain; charset=ISO-8859-15")
    xhr.open('GET', url, False)
    xhr.send()
    body = xhr.response.encode("ISO-8859-15")

    it seems to work fine.

    Maybe it's something with some headers requests is adding. Lets dig into this.

    [edit1]

    Got a failing minimal example

    [edit2]

    Hah! It's the 'User-Agent' header. Let me do some additional testing

    [edit3]

    It seems to be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1629921

  9. koenvo commented on Mar 30, 2023

    Owner

    I just released version 0.2.1 with a fix for this issue.

    @wragge @dazzag24 can you also verify it works for you?

    @jtpio your issue with seaborn is fixed when mwaskom/seaborn#3234 is released.

  10. wragge commented on Apr 2, 2023

    Author

    Confirming that my basic example now works. Thanks!

  11. koenvo commented on Apr 2, 2023

    Owner

    Thanks for both reporting this bug and testing the fix!

  12. dazzag24 commented on Apr 2, 2023

    Works for me now:

    Many thanks

  13. changed the title [-]Example of Jupyterlite use?[/-] [+]requests not working in Firefox[/+] on Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL