GithubHelp home page GithubHelp logo

Comments (33)

aredridel avatar aredridel commented on August 17, 2024

Those versions aren't compatible. Is there a reason you're using a prerelease adaro?

from adaro.

aredridel avatar aredridel commented on August 17, 2024

In general, though, that error means that Dust is getting templates compiled with a different version of dustc. Which makes sense, because adaro 1.0 includes its own dust (2.7), so using it with your own app's dust 2.6 (built using localizr or makara, I imagine) won't work.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

@aredridel

Sorry my mistake, the version of adaro is 0.1.10, yes [email protected] wont even install with [email protected].

We were using [email protected] all the time, then we notice the errors and I updated to [email protected], same problems.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

Which makes sense, because adaro 1.0 includes its own dust (2.7), so using it with your own app's dust 2.6 (built using localizr or makara, I imagine) won't work.

I will check that, thanks for direction.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Good good. I'm trying to make a 1.0 release of a lot of this stuff but it's definitely a lot to untangle with the damage dust 2.7's changes brought.

Have you tried grunt build (if you're using kraken as generated) to build new .js compiled templates?

from adaro.

aredridel avatar aredridel commented on August 17, 2024

You may also want to make sure you've only one copy of dust, npm ls dustjs-linkedin will show you all the copies in your project.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

Yes, I use grunt build then start app with NODE_ENV=testing nodemon index.js and I can see errors after, no errors in dev after nodemon index.js

Hmm, looks like only one dustjs to me:

[root@app]# npm ls dustjs-linkedin
[email protected] /home/gits/websites/app
└── [email protected] 

I checked app.js and grunt-dustjs everywhere console.log('dust.version: ', dust.version) outputs dust.version: 2.6.2

There must be something else.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Good good. Just wanted to make sure of that.

What's your configuration for engine-munger?

from adaro.

kurdin avatar kurdin commented on August 17, 2024

in config/config.json:

    "express": {
        "view cache": true,
        "view engine": "js",
        "views": "path:./.build/templates"
    },

...

    "view engines": {
        "js": {
            "module": "engine-munger",
            "renderer": {
                "method": "js",
                "arguments": [
                    { "cache": true,
                      "helpers": "import:./dust-helpers.json"
                    },
                    {
                        "views": "config:express.views",
                        "view engine": "config:express.view engine",
                        "specialization": "config:specialization"
                    }
                ]
            }
        }
    }

...

        "expressView": {
            "priority": 100,
            "enabled": true,
            "module": {
                "name": "engine-munger/lib/expressView"
            }
        },

npm ls engine-munger
[email protected] /home/gits/websites/app
└── [email protected]

I tried to upgrade to [email protected] but same errors so I keep [email protected]

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Okay. There's little difference, just version lock down of dust a bit. 0.2.5 should be fine.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

And the dust-helpers.json and specialization property you're referring to?

Can you paste one of the generated .js files from .build? I'd love to check the signature.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

dust-helpers.json

[
"../shared-modules/dust-helpers/price",
"../shared-modules/dust-helpers/dateFormat",
"../shared-modules/dust-helpers/combine",
"../shared-modules/dust-helpers/count",
"../shared-modules/dust-helpers/price",
"../shared-modules/dust-helpers/eval",
"../shared-modules/dust-helpers/lowercase"
]

specialization.json is empty for now :

{}

Regular Dust template:

{>"layouts/masterNew" /}
{<css_local}
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-datetimepicker.min.css">
{/css_local}
{<body}
{#item}
    <h1>Test</h1>
{/item}
{/body}
{<scripts_local}

{/scripts_local}

Same compiled template:

(function(dust){dust.register("events\/reports",body_0);var blocks={"css_local":body_1,"body":body_2,"scripts_local":body_4};function body_0(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.p("layouts/masterNew",ctx,{});}body_0.__dustBody=!0;function body_1(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.w("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/bootstrap-datetimepicker.min.css\">");}body_1.__dustBody=!0;function body_2(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.s(ctx.get(["item"], false),ctx,{"block":body_3},{});}body_2.__dustBody=!0;function body_3(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.w("<h1>Test</h1>");}body_3.__dustBody=!0;function body_4(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk;}body_4.__dustBody=!0;return body_0;})(dust);

throw this error:

Server listening on http://localhost:8010
::ffff:192.168.2.10 - - [07/May/2015:15:08:54 +0000] "GET /events/reports?eventId=300507 HTTP/1.1" 304 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.37 Safari/537.36"
Thu, 07 May 2015 15:08:55 GMT uncaughtException Cannot read property 'substr' of undefined
TypeError: Cannot read property 'substr' of undefined
    at peg$parseraw (/home/gits/websites/app/node_modules/dustjs-linkedin/lib/parser.js:2152:16)
    at peg$parsepart (/home/gits/websites/app/node_modules/dustjs-linkedin/lib/parser.js:410:12)
    at peg$parsebody (/home/gits/websites/app/node_modules/dustjs-linkedin/lib/parser.js:393:12)
    at peg$parsestart (/home//gits/websites/app/node_modules/dustjs-linkedin/lib/parser.js:383:12)
    at parse (/home/websites/app/node_modules/dustjs-linkedin/lib/parser.js:2691:18)
    at Object.compiler.compile (/home/gits/websites/app/node_modules/dustjs-linkedin/lib/compiler.js:30:27)
    at /home/gits/websites/app/node_modules/adaro/lib/patch/index.js:82:64
    at /home/gits/websites/app/node_modules/adaro/lib/reader/js.js:39:13
    at fs.js:336:14
    at /home/gits/websites/app/node_modules/engine-munger/node_modules/graceful-fs/graceful-fs.js:104:5

Interesting thing that page is fully loaded, I can see completed HTML in browser and only then app gets that uncaughtException error.

@aredridel Thank you for helping.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

That looks an awful lot like a dustjs 2.7-compiled template. Can you clear that out and rebuild just to make sure?

from adaro.

kurdin avatar kurdin commented on August 17, 2024

I added console.log('dust.version', dust.version); in node_modules/grunt-dustjs/tasks/dustjs.js

function compile (source, filepath, fullFilename) {
    var path = require("path"),
        dust = require("dustjs-linkedin"),
        name;

    console.log('dust.version', dust.version); 

    if (typeof fullFilename === "function") {
      name = fullFilename(filepath);
    } else if (fullFilename) {
      name = filepath;
    } else {
      // Sets the name of the template as the filename without the extension
      // Example: "fixtures/dust/one.dust" > "one"
      name = path.basename(filepath, path.extname(filepath));
    }

    if (name !== undefined) {
      try {
        return dust.compile(source, name);
      } catch (e) {
        grunt.log.error(e);
        grunt.fail.warn('Dust.js failed to compile template "' + name + '".');
      }
    }

    return '';
  }
};

Then:

[root@dev app]# rm -rf .build/
[root@dev app]# grunt build
Running "less:build" (less) task
File .build/css/app.css created.

Running "copyto:build" (copyto) task
Copied 67 files (0 unchanged), created 15 folders

Running "clean:tmp" (clean) task

Running "copyto:pretemplates" (copyto) task
Copied 176 files (0 unchanged), created 0 folders

Running "dustjs:build" (dustjs) task
dust.version 2.6.2
[dustjs] Compiled .build/tmp/templates/US/en/content-management/default-pages.js

... removed ...

dust.version 2.6.2
[dustjs] Compiled .build/tmp/templates/US/en/content-management/defaultpages/create/index.js
dust.version 2.6.2
[dustjs] Compiled .build/tmp/templates/US/en/events/reports.js

... long list removed ...

dust.version 2.6.2
[dustjs] Compiled .build/tmp/templates/US/en/travel-agents/quote.js

Running "copyto:templates" (copyto) task
Copied 176 files (0 unchanged), created 34 folders

Running "clean:tmp" (clean) task
Cleaning tmp...OK

Running "clean:build" (clean) task
Cleaning .build/tmp/...OK

[root@dev app]# cat .build/templates/events/reports.js 
(function(dust){dust.register("events\/reports",body_0);var blocks={"css_local":body_1,"body":body_2,"scripts_local":body_4};function body_0(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.p("layouts/masterNew",ctx,{});}body_0.__dustBody=!0;function body_1(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.w("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/bootstrap-datetimepicker.min.css\">");}body_1.__dustBody=!0;function body_2(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.s(ctx.get(["item"], false),ctx,{"block":body_3},{});}body_2.__dustBody=!0;function body_3(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.w("<h1>Test</h1>");}body_3.__dustBody=!0;function body_4(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk;}body_4.__dustBody=!0;return body_0;})(dust);

Same result

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Alright, I had my head too far up into the 'dust 2.7 broke everything' problem. You're right, those are not generated by a different dust.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Do you have another config file overriding config.json?

Are you starting your app with NODE_ENV=production?

This error happens when .js templates get parsed as .dust templates.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

no, there is nothing in in config/production.json , just different port number:

{

    "server" : {
        "port" : 8000
    }

}

in config/development.json I have this:

{
    "express": {
        "view cache": false,
        "view engine": "dust",
        "views": "path:./public/templates"
    },

    "view engines": {
        "dust": {
            "module": "engine-munger",
            "renderer": {
                "method": "dust",
                "arguments": [
                    { "cache": false
                    },
                    {
                        "views": "config:express.views",
                        "view engine": "config:express.view engine",
                        "specialization": "config:specialization"
                    }
                ]
            }
        }
    },

And this should tell render, not any other ENV to use js templates, in my config/config.json:

  "express": {
        "view cache": true,
        "view engine": "js",
        "views": "path:./.build/templates"
    },

   "view engines": {
        "js": {
            "module": "engine-munger",
            "renderer": {
                "method": "js",
                "arguments": [
                    { "cache": true,
                      "helpers": "import:./dust-helpers.json"
                    },
                    {
                        "views": "config:express.views",
                        "view engine": "config:express.view engine",
                        "specialization": "config:specialization"
                    }
                ]
            }
        }
    },

from adaro.

aredridel avatar aredridel commented on August 17, 2024

And which environment are you starting your node app in?

from adaro.

kurdin avatar kurdin commented on August 17, 2024

right now, I use test:
NODE_ENV=test nodemon index.js

and config/test.json has same entry for port only :

{
    "server" : {
        "port" : 8000
    }
}

I installed dustc to make sure template is compiled with [email protected] , and I can confirm this is true:

[root@dev events]# dustc -v
dustc v2.6.2
[root@dev events]# dustc reports.dust
(function(dust){dust.register("reports",body_0);var blocks={"css_local":body_1,"body":body_2,"scripts_local":body_4};function body_0(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.p("layouts/masterNew",ctx,{});}body_0.__dustBody=!0;function body_1(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.w("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/bootstrap-datetimepicker.min.css\">");}body_1.__dustBody=!0;function body_2(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.s(ctx.get(["item"], false),ctx,{"block":body_3},{});}body_2.__dustBody=!0;function body_3(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.w("<h1>Test</h1>");}body_3.__dustBody=!0;function body_4(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk;}body_4.__dustBody=!0;return body_0;})(dust);

Same template as after grunt build

from adaro.

kurdin avatar kurdin commented on August 17, 2024

This error happens when .js templates get parsed as .dust templates.

Hmm, I don't think ANY template will work at all if they parsed as dust vs js.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Yeah. They shouldn't! But this is the specific error message that results.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

It doesn't make any sense, why that string cause the error stylesheet if I change it to xstylesheet even in compiled .js template, there will be no error.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

That is definitely odd.

Here's a thing: try dust 2.5. It has different escaping of template names, and there's a possibility that's breaking it. The hacks for dealing with that are .. ugly.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

Downgraded [email protected] and [email protected] same error. I don't think its dust :)

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Alright. good, so it's not the escaping change. That is really strange.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Aye. I think to debug this I'm going to have to have a repro case.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

Looks like the problem is here: https://github.com/krakenjs/adaro/blob/v0.1.x/lib/patch/index.js#L81

src is undefined in some cases.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Oh that is just fun.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

@aredridel do you need anything from me?

from adaro.

aredridel avatar aredridel commented on August 17, 2024

A repro case would be awesome, a small app that demonstrates it. Building infrastructure to test this is going to be a pain!

from adaro.

kurdin avatar kurdin commented on August 17, 2024

Let me see what I can do.

from adaro.

aredridel avatar aredridel commented on August 17, 2024

Thank you! I'll poke at it eventually, though I'm in the process of streamlining the whole library to eliminate stuff like this in adaro 2.

from adaro.

kurdin avatar kurdin commented on August 17, 2024

@aredridel
First of all, thank you for all your help and time. This was bug in our code (templates)

in file: public/templates/errors/404.dust

we had: {>"layouts/{sessionHelper.pageLayout}/master"/} and looks like {sessionHelper.pageLayout} was not set in controller on some pages, that would lead to src is undefined in https://github.com/krakenjs/adaro/blob/v0.1.x/lib/patch/index.js#L81

So I changed {>"layouts/{sessionHelper.pageLayout}/master"/} to {>"layouts/master"/} and errors are gone now.

May be in adaro you can try to check in src is undefined then show some message in logs.

Thanks again.

from adaro.

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.