[web-devel] juliusFile in yesod 0.8 eating all memory

Anton Cheshkov acheshkov at gmail.com
Fri Apr 29 17:11:39 CEST 2011


What package do need to upgrade to get away this problem ?

Thanks.

2011/4/29 Greg Weber <greg at gregweber.info>

> As an alternative to orphan instances, given the recent refactoring it
> should be easy to now make Julius (and Coffee) a separate package (with the
> aeson dependency).
>
> On Fri, Apr 29, 2011 at 7:45 AM, Michael Snoyman <michael at snoyman.com>wrote:
>
>> On Fri, Apr 29, 2011 at 5:32 PM, JP Moresmau <jpmoresmau at gmail.com>
>> wrote:
>> > Right, found it.
>> >
>> >>>> instance (ToJSON a)=> ToJavascript a where
>> >>>>       toJavascript =toJavascript . toJSON
>> >
>> > That used to work but now seems to go into an infinite loop. I've
>> > replaced it by:
>> >
>> > instance (ToJSON a)=> ToJavascript a where
>> >       toJavascript =fromLazyText . decodeUtf8  . encode . toJSON
>>
>> Unfortunately, that's the best we can do here, since Javascript only
>> works with Text, and aeson only works with ByteString.
>>
>> > and everything works again. Not very elegant, have I missed something?
>> > Shouldn't that instance be part of Yesod somewhere? I mean if we
>> > standardize on Aeson, and we want variables in Javascript, it makes
>> > sense to serialize ToJSON instances in a Julius template.
>>
>> Good catch, it's supposed to be in yesod-json, but it's commented out
>> right now. It was probably part of the changeover from json-types to
>> aeson and got forgotten. I'm not a huge fan of the placement of this
>> instance (it *is* an orphan), but the alternative is adding aeson as a
>> dependency to hamlet.
>>
>> Michael
>>
>> > JP
>> >
>> > On Fri, Apr 29, 2011 at 4:06 PM, JP Moresmau <jpmoresmau at gmail.com>
>> wrote:
>> >> juliusFile, I'm not running any scaffolded site, I've built everything
>> >> with 1s and 0s. (-:
>> >> Changing to juliusFileDebug results in the same behavior.
>> >>
>> >> JP
>> >>
>> >> On Fri, Apr 29, 2011 at 3:56 PM, Michael Snoyman <michael at snoyman.com>
>> wrote:
>> >>> Are you running juliusFile or juliusFileDebug? (The scaffolded site
>> >>> uses the latter by default.)
>> >>>
>> >>> Michael
>> >>>
>> >>> On Fri, Apr 29, 2011 at 4:52 PM, JP Moresmau <jpmoresmau at gmail.com>
>> wrote:
>> >>>> Hi all,
>> >>>>
>> >>>> I've just upgraded to Yesod 0.8. I've changed all my Strings into
>> >>>> Texts, and all my Data.JSON.Types into Data.Aeson.Types. I use these
>> >>>> JSON objects in julius templates, by adding the orphan instance:
>> >>>> instance (ToJSON a)=> ToJavascript a where
>> >>>>       toJavascript =toJavascript . toJSON
>> >>>>
>> >>>> (Removing that instance causes compilation error, and I had it when I
>> >>>> was using json-types).
>> >>>> addJulius works fine when it contains Javascript code. However on one
>> >>>> page I use juliusFile to load an external template. This eats all my
>> >>>> memory and never returns under Warp when I launch the compiled exe (I
>> >>>> see "thread killed" messages in the console, though), and in GHCi
>> >>>> crashes with "out of memory".
>> >>>> The code hasn't changed and was working fine in yesod 0.7 before the
>> >>>> upgrade. If I remove juliusFile the page displays instantly.
>> >>>>
>> >>>> Any idea? I'm a bit stumped. I suppose I'm going to remove each of my
>> >>>> variables in the julius file to narrow it down, but if anybody has
>> any
>> >>>> insight...
>> >>>>
>> >>>> Thanks!
>> >>>>
>> >>>> --
>> >>>> JP Moresmau
>> >>>> http://jpmoresmau.blogspot.com/
>> >>>>
>> >>>> _______________________________________________
>> >>>> web-devel mailing list
>> >>>> web-devel at haskell.org
>> >>>> http://www.haskell.org/mailman/listinfo/web-devel
>> >>>>
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> JP Moresmau
>> >> http://jpmoresmau.blogspot.com/
>> >>
>> >
>> >
>> >
>> > --
>> > JP Moresmau
>> > http://jpmoresmau.blogspot.com/
>> >
>>
>> _______________________________________________
>> web-devel mailing list
>> web-devel at haskell.org
>> http://www.haskell.org/mailman/listinfo/web-devel
>>
>
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>
>


-- 
Best regards,
Cheshkov Anton
Phone: +7 909 005 18 82
Skype: cheshkov_anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110429/194f97c2/attachment-0001.htm>


More information about the web-devel mailing list