Git Product home page Git Product logo

Comments (5)

miracle2k avatar miracle2k commented on August 11, 2024

I'm fine with improving the error, though I'm -1 on silencing it. I know that Django traditionally has a policy of ignoring errors in templates, though IIRC from discussions on django-dev, at this point even the Django devs feel conflicted about this.

Is there a particular use case you have in mind where a missing file is not a bug that the developer would want to be notified about?

from webassets.

ravishi avatar ravishi commented on August 11, 2024

No, there is no special use case. I just think that getting HTTP 500 errors because of a mispelled js file path is not right.

Even in the development environment, when I misspell a js file path, and I'm not using webassets, I'll be noticed about that by a 404 error or a javascript console error on my browser developers tools, not by a TemplateSyntaxError nor IOError on the server side. So I thought that webassets should act this way.

from webassets.

miracle2k avatar miracle2k commented on August 11, 2024

The browser ignores files it can't load, but that's not to say that a separate preprocessing step on the server like webassets needs to persist that behavior. I guess I just don't see the advantage.

It makes sense for the browser to ignore the files it can't find and still display a site, because that still gives the user something, which is better than showing nothing. On the other hand, as a developer, I want to be made aware of an error like that as prominently as possible; everything else is just going to cost me more time trying to find a bug.

Now, there's a chance that such an error could trickle down to the user if the developer where to deploy a buggy site, but ideally, that wouldn't happen (and raising a big fat error is going to help that it won't), and I'd say the benefits outweigh the costs.

Anyway, I might be willing to include an option to toggle on a silent-error behavior if it turns out a lot of people want it. Feedback welcome.

from webassets.

dguaraglia avatar dguaraglia commented on August 11, 2024

I think hiding the error is the wrong thing to do, specially considering that once the assets are packaged it's damn difficult to check if a script has been included or not. At least a nice warning should be shown in development, and maybe even stop the bundling in production unless you expressely specify an option in the configuration file or command line.

I think hiding the error misses the principle of 'least surprise' that Django is based on. If you are old enough to remember the 'magic-removal branch' you know what I mean.

from webassets.

miracle2k avatar miracle2k commented on August 11, 2024

I'm closing this for now. I just had a look at implementing a custom exception type with a custom error message, but there's really no good solution. There's actually different OSErrors that could be raised, either by the code that checks whether the bundle needs to be rebuilt and thus needs to look at the source file timestamps, or the code that tries to do the actual building. There are going to be more in the future. I don't really want to handle all these cases separately.

On the other hand, you can't really check the filenames for existance earlier. It has potential performance implications, and isn't correct either. For example, if a path were checked once it is added to the bundle, that same file may no longer exist when the build happens (i.e. it'd be effectively a race condition). This might mostly be an academic distinction, but still.

In the end "OSError: file XYZ does not exist", together with the stack trace that clearly points into the webassets library, should be a clear enough indication of what's wrong.

from webassets.

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.