pauleveritt / psc

Prototype of new repo for the PyScript Collective.
Other
0 stars 0 forks source link

BUG: Apparent MIME type issue loading pyodide.asm.js #32

Open tildebyte opened 2 years ago

tildebyte commented 2 years ago

I say "apparent" because it's entirely possible that my environment has some kind of issue.

Note that this is attempting to run a new example (babylonjs-minimal-demo), but trying to run the "Hello, World" example yields the same result, with the addition of server-side 500s when trying to GET 'hello_world.css' and 'hello_world.js'.

Thorium 105.0.5114.0 (performance build of ungoogled-chromium), Win 11, Py 3.10

16:40:23.563 main.ts:36        RUNTIME READY
16:40:23.563 main.ts:36        config set!
16:40:23.563 main.ts:36        initializers set
16:40:23.563 main.ts:36        post initializers set
16:40:23.563 main.ts:36        post initializers set
16:40:23.563 main.ts:36        post initializers set
16:40:23.564 main.ts:36        post initializers set
16:40:23.564 pyscript.ts:110   connected
16:40:23.566 main.ts:36        config set!
16:40:23.566 main.ts:36        config set Object
16:40:23.567 main.ts:36        Initializing runtimes...
16:40:23.575 main.ts:36        creating pyodide runtime
16:40:23.602 pyodide.asm.js:1  Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
16:40:23.602 main.ts:36        Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: http://127.0.0.1:3000/static/pyodide.asm.js

Firefox 103.0.1, Win 11, Py 3.10

[pyscript.js:32134:13]        RUNTIME READY 
[pyscript.js:32401:13]        config set! 
[pyscript.js:32406:13]        initializers set 
[pyscript.js:32411:13]        post initializers set 
[pyscript.js:32416:13]        post initializers set 
[pyscript.js:32421:13]        post initializers set 
[pyscript.js:32416:13]        post initializers set 
[pyscript.ts:110:5]           connected 
[pyscript.js:32401:13]        config set! 
[pyscript.js:32510:15]        config set Object { autoclose_loader: true, runtimes: (1) […] } 
[pyscript.js:32522:15]        Initializing runtimes... 
[HTTP/1.1 200 OK 0ms]         GET http://127.0.0.1:3000/static/pyodide.js 
[babylonjs-minimal-demo]      The script from “http://127.0.0.1:3000/static/pyodide.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type. 
[pyscript.js:32084:13]        creating pyodide runtime 
[HTTP/1.1 200 OK 0ms]         XHR GET http://127.0.0.1:3000/static/packages.json 
[HTTP/1.1 200 OK 0ms]         XHR GET http://127.0.0.1:3000/static/pyodide_py.tar 
[HTTP/1.1 200 OK 11ms]        GET http://127.0.0.1:3000/static/pyodide.asm.js 
[HTTP/1.1 200 OK 0ms]         GET http://127.0.0.1:3000/favicon.png 
[babylonjs-minimal-demo:1:1]  Loading failed for the module with source “http://127.0.0.1:3000/static/pyodide.asm.js”. 
[babylonjs-minimal-demo]      Loading module from “http://127.0.0.1:3000/static/pyodide.asm.js” was blocked because of a disallowed MIME type (“text/plain”). 
[pyscript.js:32482:17]        Uncaught (in promise) TypeError: error loading dynamically imported module 
pauleveritt commented 2 years ago

Ah, yes, this is where I spent half a day flailing. I propose we use this as a deep-dive, to then decide if you think this effort is worth pursuing?

I will show you how to debug this, and we'll then discuss refactorings to better isolate and test this. It is certainly a bug magnet.

pauleveritt commented 2 years ago

@tildebyte In general:

  1. Do you think you'd like us to pursue this PSC implementation, with the site/app/docs?
  2. Would you like to co-write any parts of it with me, diary-style?
tildebyte commented 2 years ago
  1. Yes
  2. I think my best use of time would be testing/note-taking/bug reporting&verifying - I simply know too little about most of what you're doing in here - although I'll happily review PRs; I might not feel comfortable approving them outright, depending.

Having said that, I do have experience with pytest, linters, and CI generally, and specifically GH Workflows and custom Actions

pauleveritt commented 2 years ago

On (2), it's kind of the idea. If you read through the diary, I build the system one piece at a time, with narrative.

We would go through each piece, agree/change, then proceed to next.