Skip to content

locales.js generating multiple times in development environment causes javascript parse error #1

@nathany

Description

@nathany

After struggling with a JavaScript parse error in locales.js for quite a while, I determined the cause. The error is a missing } even though the code looks/lints fine. It is a result of multiple near-simultaneous requests in development mode.

We have a route to a stylesheet action that pulls the CSS from a database. When a page is hit (in development), the generate_locale_javascript filter is fired once for the page and again when the page loads the stylesheet action. My assumption is that this results in a partially overwritten locales.js being returned, hence the parse error.

My solution for now is as follows:
skip_after_filter :generate_locale_javascript, :only => :stylesheet

I'm submitting this so others are aware of the issue, and perhaps we can come up with a better solution in Babilu itself. Regenerating only if the yml files change should at least reduce, if not eliminate the issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions