Giter VIP home page Giter VIP logo

Comments (3)

ryanking13 avatar ryanking13 commented on June 12, 2024

Thanks for the report @ibdafna. pyodide.http.open_url relies on XMLHttpRequest and AFAIK XMLHttpRequest is not supported in the service worker.

from pyodide.

ibdafna avatar ibdafna commented on June 12, 2024

Hi @ryanking13, thanks for taking a look. Whilst you're technically correct about XHR not being supported in Service Workers, there is a polyfill called xhr-shim (I mention that in the initial post), and the official Pyodide documentation advises installing that polyfill as a precondition for using Pyodide in a Service Worker. The polyfill does seem to work outside the context of Pyodide, so I'm inclined to believe there's an issue somewhere else.

from pyodide.

ryanking13 avatar ryanking13 commented on June 12, 2024

Oh, sorry I didn't read your post closely enough.

Could you try using XMLHttpRequest directly instead of using open_url and compare the response (content, status code, headers) when running it in main thread without xhr-shim and in the service worker?

You can see the implementation of open_url here:

def open_url(url: str) -> StringIO:
"""Fetches a given URL synchronously.
The download of binary files is not supported. To download binary
files use :func:`pyodide.http.pyfetch` which is asynchronous.
Parameters
----------
url :
URL to fetch
Returns
-------
The contents of the URL.
"""
req = XMLHttpRequest.new()
req.open("GET", url, False)
req.send()
return StringIO(req.response)

from pyodide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.