question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG - Develop] Global Scripts loading doesn't catch parse errors

See original GitHub issue

Describe the bug

When there’s an error with loading a global scripts module, e.g. it imports the Room class but that class has a syntax error, the loading error isn’t caught and the traceback points to this line with a KeyError

To Reproduce

Steps to reproduce the behavior:

  1. Create a simple global script which imports a class such as Room from your game dir, and add it to settings.py
  2. Introduce a syntax error to your Room class, such as an extra space in an indent.
  3. Reload the server.
  4. See error

Expected behavior

It’d be more useful if there was an error thrown which indicated that the script had failed being loaded (and, ideally, why), as the current error invariably leads people to think there is a problem with the global scripts dict in settings.py.

Develop-branch commit

f093c8bcb

Additional context

I feel like it should be catching that kind of an error in class_from_module or it should at least be throwing an exception in load_data but neither seem to be doing so. Instead, they just silently don’t load the script.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
InspectorCaracalcommented, Oct 2, 2022

The error is much clearer, which is a definite improvement, but I’d prefer if the game failed to start due to a broken global script rather than continuing to start without it. If I have a global script, the chances that I have other systems relying on it are very high, so having the game start without that script available could cause a cascade of broken systems.

1reaction
InspectorCaracalcommented, Oct 2, 2022

@Henddher That’s the one!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to tell if a <script> tag failed to load - Stack Overflow
Well, yes if the file LOADS and there is an error in the file itself, but if the file is not served up,...
Read more >
What causes a Script error and how to solve them · Raygun Blog
A Script error in Raygun is one of the most cryptic error messages you may encounter. In this post we'll discuss in detail...
Read more >
Error handling, "try...catch" - The Modern JavaScript Tutorial
So, an error inside the try {...} block does not kill the script – we have a chance to handle it in catch...
Read more >
Window: error event - Web APIs - MDN Web Docs - Mozilla
The error event is fired on a Window object when a resource failed to load or couldn't be used — for example if...
Read more >
JS: Error Handling - Medium
The errors that occur on the reading phase are called “parse-time” errors and are unrecoverable (from inside that code). Thats because the engine...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found