An app would hang if attempting "import nonexistent_module" from CDN
See original GitHub issueAn app would hang if attempting “import nonexistent_module” from CDN, due to uncaught error in brython.js
. Is it possible to have brython raise an ImportError
instead?
Repro:
-
Content in
index.html
... <script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython_stdlib.min.js"></script> <script type="text/python" src="main.py"></script> ...
-
Content in
main.py
try: import optional_module except ImportError: print("That is fine")
Expects to see “That is fine” in the console.
What actually happened is that the app hangs, with the following output on the browser console. The first 2 or 3 lines are expected, but can Brython or javascript recover from a “Cross-Origin Request Blocked” request?
Error 404 means that Python module cowsay was not found at url http://localhost:8000/optional_module.py
Error 404 means that Python module cowsay was not found at url http://localhost:8000/__init__/optional_module.py
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/Lib/site-packages/optional_module.py?v=1615571704659. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Javascript exception: DOMException: A network error occurred.
...
test is js exc is recursion error DOMException: A network error occurred. NetworkError: A network error occurred.
...
Uncaught Error:
$factory https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js line 1 > eval:1
loop https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js:1
onsuccess https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js:1
onsuccess https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js:1
brython.min.js line 1 > eval:1:7500
$factory https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js line 1 > eval:1
loop https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js:1
onsuccess https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js:1
onsuccess https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.1/brython.min.js:1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
OneNote hangs while importing notes - Microsoft Community
I am OK with losing that content I tried to import. I just want to get into the app so that I can...
Read more >If an app on your iPhone or iPad stops responding, closes ...
If an app on your iPhone or iPad doesn't work as expected, try this. ... When you do this, you might lose data...
Read more >Crash when importing a LandXML file into AutoCAD ...
When attempting to import a LandXML file into AutoCAD Architecture or MEP, the application crashes.
Read more >Studio crashes and hangs when the Import button is selected ...
Try either clicking on the Studio application tab on the Windows task bar or pressing ALT-TAB on your keyboard to cycle through the...
Read more >How do you prevent Lumion from hanging or crashing when ...
1. Here's how. If you try to import a model that is too detailed for your computer, Lumion may sometimes hang or run...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did try this Javascript program:
The console prints this:
Interestingly, I notice that the
ImportError
can be caught now, and theexcept
clause can be run. Last time @PierreQuentel and I both tested this issue 3 months ago, it did not work at that time. The only difference today is I run it with a newer version of browser. Just a FYI.