BundleTransformer: Concurrent Less file translations with wrong result

Hello Andrey, nice to meet you.

We are using BundleTransfomer on a web site which makes use of it in order to bundle Less resources. We are experimenting two diferent behaviours that we don’t expect.

The first one, and probably the guilty of the second is a problem related with threads. We have at the very top of the Application_start in global.asax the registry of all our less bundles. Something like that:

        protected void Application_Start()
        {
            ViewEngines.Engines.Clear();

            ViewEngines.Engines.Add(new RazorViewEngine());

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            //Our helper that register the bundles
            BundleConfig.RegisterBundles(BundleTable.Bundles);

The problem happens when we start the application and there are various requests to the application, it seems not to be thread-safe and is accessing multiple times to the Process method of TransformerBase which do the trasformation process thanks to LessTranslator class. We don’t know why it isn’t a thread-safe process and if it is possible to use BundleTransformer in a thread-safe way without forking your development.

You can see in this log in which way is doing this, the number at the start is the threadId and the next info after the arrow is the less file that is processing:

123 -> “asset-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 126 -> “asset-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 138 -> “asset-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 54 -> “asset-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 119 -> “asset-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 61 -> “asset-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 61 -> “result-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 119 -> “result-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 54 -> “result-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 61 -> “asset-/PrefWeb/Content/kendo/web/kendo.rtl.less” 54 -> “asset-/PrefWeb/Content/kendo/web/kendo.rtl.less” 119 -> “asset-/PrefWeb/Content/kendo/web/kendo.rtl.less” 138 -> “result-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 138 -> “asset-/PrefWeb/Content/kendo/web/kendo.rtl.less” 123 -> “result-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 123 -> “asset-/PrefWeb/Content/kendo/web/kendo.rtl.less” 126 -> “result-/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” 126 -> “asset-/PrefWeb/Content/kendo/web/kendo.rtl.less” 61 -> “result-/PrefWeb/Content/kendo/web/kendo.rtl.less”

You can appreciate how it’s doing repeatedly (5 times) the process of translating the less file “/PrefWeb/Content/kendo/web/kendo.common-bootstrap.less” in threads with numbers 123, 126, 138, 54 and 119.

The second problem is the main problem for us, because in some situations that we can reproduce but with no sense for us, the result of the translation of a less file returns a empty value, I mean, it returns an empty CompiledContent in the CompilationResult returned by the Compile method of LessCompiler, it sounds like a problem with the lessjs because the JSON object that returns seems to have this compiledCode property, but it’s empty.

You can see this log and empty response of lessjs compilation result.

Bundle-Transformer-github-report-problem

Do you know how it’s possible?

Thanks in advance.

Regards, José Carlos Ruiz.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Hello Andrey!

We did the tests linking JavaScriptEngineSwitcher.V8 and JavaScriptEngineSwitcher.Core and we were surprised when finally get the same result, an empty “compiledCode” property so… We started to review some changes we did in the past in a VirtualProvider and seems to be there the problem, because when we remove this virtialProvider the problem disappear

So, I’m going to close the ticket, everything here is working nice.

Thank you very much for your time. Regards.