The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-06-29

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
01:31 tchaves joined #mojo
02:12 noganex joined #mojo
02:43 leoj joined #mojo
02:44 PryMar56 joined #mojo
02:58 tchaves1 joined #mojo
03:25 itaipu joined #mojo
04:53 leoj joined #mojo
04:58 lluad joined #mojo
05:41 inokenty-w joined #mojo
06:15 arpadszasz joined #mojo
06:21 punter joined #mojo
06:46 jberger quiet day
06:53 kes joined #mojo
07:08 Lee non-blocking is hard :/
07:08 Lee recent bug fixes in mojo have revealed some bugs in our app
07:19 trone joined #mojo
07:30 * Lee wonders if a "mojo best practices" guide is a good idea
07:30 AndrewIsh joined #mojo
07:30 stephan48 if its keept versioned and up2date
07:31 sri the cookbook is meant to be a bit of a best practices collection
07:32 Lee FWIW the bug we had was ->redirect_to within a delay block without return before it, so we got some double rendering of pages
07:32 Lee which is similar to another bug we had recently
07:33 * Lee *assumes* it makes sense to always prefix ->redirect_to with return
07:39 Vandal joined #mojo
08:02 icjs joined #mojo
08:07 osfabibisi joined #mojo
08:11 jberger Lee: yeah probably (assuming it isn't already the end of whatever code you are running
08:11 jberger or unless it is in an under in which case you want to be sure to return 0 after setting the redirect target
08:12 Lee yeah that makes sense
08:13 jberger I often build myself a helper for things like this: https://github.com/jberger/Galileo/blob/master/lib/Galileo.pm#L151-L157
08:14 jberger so that later I can use it in unders in a more semantic way: https://github.com/jberger/Galileo/blob/master/lib/Galileo.pm#L194-L197
08:15 Lee yeah
08:15 Lee i think this is more about the slight change in behaviour you need to be aware of in non-blocking flow
08:16 jberger I don't follow you
08:17 jberger (perhaps I've just internalized non-blocking flow to the point where it feels no different :-P)
08:17 Lee well in the example here (the bug we had) we weren't doing return $c->redirect_to, which ended up being a bug when i wrapped it in a delay block
08:18 Lee maybe this isn't quite right given it was working before some bug fixes in mojo itself
08:18 Lee here's the commit message for the other fix i needed to make if you're interested: https://gist.github.com/leejo/3d5ae177d79aab718c5222c6bea92d92
08:22 jberger Yeah it is the same thing, just masked by the IOLoop
08:25 Lee it *seems* to me (and i may be wrong here) that you can end up rendering more than once when in an IOLoop, which is where i mean by the slight change in behaviour
08:25 Lee certainly we were seeing this
08:26 Lee of course this is necessary (?) for websockets and the like
08:26 Lee (i'm guessing here, haven't played with websockets yet)
08:28 sri i don't see the relevance of the non-blocking part
08:28 Lee maybe it's not
08:28 sri you can't do "$c->redirect_to(...) if $foo; $c->render(...);"
08:30 nic Lee: yeah, you can make exactly the same mistake in blocking code
08:30 * nic whistles and avoids eye contact
08:30 Lee hehe
08:35 salva joined #mojo
08:39 marty joined #mojo
08:49 ashimema_ joined #mojo
09:06 meshl joined #mojo
09:25 dotan joined #mojo
09:40 vytas joined #mojo
10:04 metasoft joined #mojo
10:27 arpadszasz joined #mojo
10:29 metasoft I'm writing a web service in Mojo, what are the best practices for logging?
10:34 * ashimema_ listens in.. would also be interested in a logging with mojo best practice
10:59 ashimema_ Anyone able to shed any light on a redirect problem I'm having?: https://ssl.thorsen.pm/paste/142a5ecce48f
11:00 ashimema_ I can see the encoding of the # character is good in most cases.. but I'm wondering if there's a simple way I can turn it off for my case?
11:01 CHYC ashimema: You probably want to define a fragment http://mojolicious.org/perldoc/Mojo/URL#fragment
11:07 ashimema_ sorted it
11:07 ashimema_ yeah.. i was begin daft
11:07 ashimema_ thanks
11:09 nic end daft
11:10 nic metasoft: I'm struggling to think what would constitute best practices for logging.  What sort of things do you have in mind?
11:33 marcus best practices are to log
11:33 marcus :p
11:33 nic and log that you've just logged
11:34 bpmedley metasoft: do you have a AccessLog plugin?
11:35 nic (not to be confused with Log::Access)
11:35 orev joined #mojo
11:44 sd joined #mojo
11:44 sd hello
11:45 sd I am upgrading from an older version (5.72) to the latest one (6.66) and I keep getting a warning 'Use of uninitialized value $name in hash element' in Mojolicious/Controller.pm line 67
11:45 sd I tracked this all the way back and it's trigger by calling param() to get all the request parameters
11:46 sd I realize this has changed now, but I am struggling to see how
11:47 bpmedley https://github.com/kraih/mojo/wiki/Upgrading
11:47 bpmedley sd: note the param section
11:50 sd thank you - very useful - I had not seen this
11:52 sd although, still, what is the proper way to get placeholder values?
11:52 sd I've found them in 'mojo.captures' but is there a 'proper' way of obtaining them?
11:53 Lee $c->param( 'capture_name' )
11:54 sd so param() no longer includes stash'ed values?
11:54 Lee they'll be in $c->stash
11:55 sd gotcha
11:55 sd thank you
11:55 sri i kinda want to give this a better review, but with so little effort put into the pull request description... https://github.com/kraih/mojo-pg/pull/25
11:56 sri without knowing more about motivations pointing out flaws in the implementation is a bit of a waste of time
11:58 sri hmm, perhaps MOTIVATION should be a block in the pull request template
12:02 good_news_everyon joined #mojo
12:02 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vobN4
12:02 good_news_everyon mojo/master af6d2dd Sebastian Riedel: add motivation section to the pull request template
12:02 good_news_everyon left #mojo
12:04 good_news_everyon joined #mojo
12:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vobNM
12:04 good_news_everyon mojo/master cebbec8 Sebastian Riedel: more consistent descriptions
12:04 good_news_everyon left #mojo
12:07 sri i feel like there's a better template to be written
12:08 sri the issue template worked out really well
12:08 sri https://github.com/kraih/mojo/blob/master/.github/ISSUE_TEMPLATE.md
12:09 sri i want something as straigt forward as that for pull requests too
12:14 sri btw. laptop delivery times are now almost two weeks, so it looks like i'll be incapacitated for quite some time :(
12:15 leoj joined #mojo
12:17 nic I knew it would come to this
12:17 nic "Make them small enough to fit inside delivery trucks," I said, but would they listen?  Of course not.
12:21 val40 joined #mojo
12:30 metasoft nic: Should we log every call to a method in a controller, every exit of the controller, should we log json rather than a simple text message, use a transaction id to be able to identify a request which may span other services?
12:32 punter joined #mojo
12:33 bpmedley sri: http://fossies.org/linux/video.js/PULL_REQUEST_TEMPLATE.md <-- do you like the format of this one?
12:34 sri bpmedley: no
12:36 nic metasoft: The first thing is, why are you logging?  Is it to analyse performance, to create a financial audit trail, to fine tune an online game, to help the poor sod who's later debugging a problem, to throttle the io so the throughput isn't too fast, ...?
12:37 metasoft nic: yes, performance and debugging problems
12:38 nic My limited-value advice is to maximise the value of your logging by selecting key 'milestones' that will give you that value, rather than trying to log everything
12:39 metasoft Logging with JSON I'm interested, see https://journal.paul.querna.org/articles/2011/12/26/log-for-machines-in-json/
12:41 bpmedley sri: is it the general format, checklist approach, or something else?
12:41 nic If you have hot reloads via hypnotoad and are allowed to edit on 'production' then it's easy to add pertinent debug logging wherever the focus of your investigation points
12:44 sri bpmedley: all, it's just not good
12:47 nic sri: Is it possible to attach code to a worker shutdown?  I'm thinking of when a worker is asked to shutdown (periodic reload) having it export some data from the app -- current developer-defined 'stats'
12:48 bpmedley nic: can you use an END block?
12:49 nic ah, yes, that should work
12:49 nic thanks bpmedley
12:50 che-quest joined #mojo
12:50 gizmomathboy joined #mojo
12:51 nic hmm, that's probably too late in the cycle
12:51 che-quest hi broths! about Mojo::Pg i have thing
12:53 che-quest a thing about inheritance of Mojo::Pg and Mojo::Pg::Database
12:53 bpmedley nic: Is that because you need access to a resource that is no longer there?
12:54 nic You want to do the stuff at the start of shutdown, not at the point the app obj is being destroyed
12:56 neilhwatson joined #mojo
12:56 che-quest in short, i have opinion in my patch https://github.com/kraih/mojo-pg/pull/25
12:56 nic I'll have a look at the code and see if anything jumps out
13:06 ramortegui joined #mojo
13:10 sri che-quest: that's not an opinion, just a list of very short change descriptions
13:14 che-quest the long descr is expanding some functionality and so inherite the mojo pg classes
13:19 ashimema_ hmm.. so recently if I watch a minion started in the console.. I periodically get a
13:19 cuechan joined #mojo
13:19 ashimema_ `[1]    1904 killed     carton exec ./script/rebus minion worker`
13:20 ashimema_ seem to get the same for other commands too..
13:20 ashimema_ is there a recent change that does somthing to kill longer running processes in mojo?
13:20 ashimema_ or has my server just recently lost the will to live.
13:20 ashimema_ this corresponds with a recent update to latest mojo
13:21 leoj joined #mojo
13:22 ashimema_ hmm
13:23 ashimema_ I can't even run the 'version' command without it beign killed
13:24 nic Do they get killed if they become unresponsive (or take too long to respond)?
13:26 * ashimema_ investigate with git bisect.. looks like it might be my fault somewhere
13:28 ashimema_ feels like that's the case nic
13:28 ashimema_ but I have no idea why it's reached this point
13:29 val40 or maybe running out of memory
13:29 * nic tries to hide the 2 million workers fighting on a 2-core box
13:29 ashimema_ funny you should say that val40
13:30 ashimema_ I jsut got an 'unable to allocate memory' message
13:30 nic What OS are you on?
13:30 * val40 ***** :)
13:30 ashimema_ debian
13:30 ashimema_ jessie
13:30 nic can you run 'top'?  or 'free -m'?
13:31 ashimema_ free claims I still have lots to spare
13:31 nic does it say you're using any swap?
13:31 bpmedley ashimema_: could it be a ulimit issue?
13:31 val40 bpmedley, good guess
13:34 ashimema_ interesting..
13:34 ashimema_ on running any mojo command it rockets up to filling all available memory then is killed
13:34 ashimema_ wonder whats changed
13:37 Kripton joined #mojo
13:38 bpmedley ashimema_: did your startup method change?
13:39 ashimema_ not that I know of
13:39 ashimema_ :(
13:40 ashimema_ I think it's perhaps one of the plugins I'm using going wild
13:40 ashimema_ I've narrowed it down to updating all my dependancies
13:40 ashimema_ just trying to narrow down which one now
13:55 cpan_mojo Mojo-SMTP-Client-0.11 by OLEG https://metacpan.org/release/OLEG/Mojo-SMTP-Client-0.11
14:04 jkrizansky joined #mojo
14:07 nic bpmedley: success!  can attach a callback to the 'finish' event
14:11 nic https://gist.github.com/niczero/f2fe730e2562d32933a072475eb8af50
14:12 marty joined #mojo
14:17 gabiruh joined #mojo
14:29 ptolemarch joined #mojo
14:51 vicash joined #mojo
14:57 bpmedley ashimema_: did you find the culprit?
14:59 bpmedley nic: wow, took me a while to realize that's an IOLoop event; awesome example!
15:00 meshl joined #mojo
15:03 tchaves joined #mojo
15:10 Kripton joined #mojo
15:31 disputin joined #mojo
15:38 disputin joined #mojo
15:40 disputin1 joined #mojo
15:49 lluad joined #mojo
15:50 tchaves1 joined #mojo
15:50 PryMar56 joined #mojo
16:13 ashimema_ still digging
16:13 ashimema_ it's the Swagger2 lib
16:13 ashimema_ everything works nice at version 0.80.. but at 0.82 it explodes
16:14 ashimema_ I'm just narrowing it down a bit more.. installing 0.81 to see if that also has the issue..
16:14 ashimema_ then will try to build a failing test case for batman
16:14 ashimema_ sorry dude
16:17 batman ashimema_: pretty sure it's in JSON::Validator
16:18 ashimema_ mm.. perhaps a function in JSON::Validator that only gets called by a recent Swagger2?
16:19 ashimema_ latest JSON validator with an older Swagger2 works
16:19 batman https://github.com/jhthorsen/json-validator/commit/a0555241a3bfdc522635d47a5a30e464a240270f
16:20 ashimema moving to #swagger
16:20 batman oh! sorry. yeah, wrong channel...
16:21 ashimema no worries
16:32 punter joined #mojo
16:34 leoj joined #mojo
17:08 cpan_mojo Mojolicious-Plugin-AssetPack-1.16 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-AssetPack-1.16
17:26 disputin joined #mojo
17:31 Kripton joined #mojo
17:36 punter joined #mojo
17:58 gtodd joined #mojo
17:59 nnms joined #mojo
18:02 dod joined #mojo
18:03 val40 joined #mojo
18:04 zivester joined #mojo
18:10 gtodd say there's this 10 year old collection of modules/packages ... *.pm files where  you:   use OldeModule ':all' ; and then call methods to either print / calculate and print results to STDOUT  from data on STDIN or a DBI connection ... probably more than a few workstations have such a collection
18:12 gtodd ... to "mojoize" them in a lazy way you can just make a lite app that uses  the module (and maybe do something with base or inheritance depending on things are written) ... and add some restful routes that call the methods from your OldeModule ... and print the results to the web instead of your console ... "ducttaping the ducttape"
18:17 gtodd has anyone collected examples of this uhh "pattern" (or antipattern) in the docs .. I thought the official git repo had a bunch hacking examples for integrating Mojo various kinds of "alien" modules  (traditional perl OO;  Moose, Moo, Inside Out?! but .... I don't see it on https://github.com/kraih/mojo/wiki/Example-applications
18:18 gtodd just asking in here while I go on looking ... answer if it jogs your memory :-)
18:27 gtodd something like BibSpace is a possible example https://github.com/vikin91/BibSpace but I thought there wrere others where Mojo was used to "wrap" the existing errm "business logic" (?) in the modules with a web UI
18:27 vicash gtodd: create a Model that invokes all your old modules as functions. then use the Mojo lite app to invoke the model functions as needed on request
18:27 asarch joined #mojo
18:27 vicash this way you can decouple the model from the app and test each function separately too
18:30 gtodd a perfect ... sort of like TobyInk's "build your own perl" article a few years back
18:33 gtodd wow I can gradually move them *all* in to a bunch of properly named / organized  .pm models and then use those  for building any OldeModule mojo app I want
18:33 gtodd vicash++ thanks !
18:35 leoj joined #mojo
18:47 Bean joined #mojo
18:58 Bean does Mojo::Pg or DBD::Pg do any sort of input sanitization? My site is not vulnerable to sql injection but I haven't done anything to prevent it
19:00 jberger Bean: sql injection is **MOSTLY** about using parameter binding rather than direct string interpolation
19:01 jberger which of course Mojo::Pg allows (via DBD::Pg/DBI)
19:01 jberger how do you know that your site is not vulnerable?
19:04 Bean I have user input that gets stored in a table in my database. When I input something like ');select * from table;-- it gets safely stored in the database
19:04 preaction you don't need to sanitize the input if you input it safely
19:05 Bean however if I do the exact same query in psql, it breaks things as expected
19:05 preaction because you typed it in to the query, and that's not safe
19:07 Bean so doing pg->db->query(etc...) is different
19:08 preaction provided you are not concatenating that value into the SQL you're using
19:08 jberger related: http://bobby-tables.com/
19:12 Bean jberger: thanks! that comic is what got me to check
19:23 jberger basically as long as you always use placeholders rather than interpolation you are mostly ok
19:23 jberger SELECT colname FROM tablename WHERE id=?
19:23 jberger rather than
19:23 odc joined #mojo
19:23 jberger "SELECT colname FROM tablename WHERE id=$id"
19:24 jberger for any statement of course, not just select
19:26 marty joined #mojo
19:30 Bean aaah I just assumed that using placeholders worked the same as concatenating
19:31 jberger if you interpolate (or concatenate) then someone might be able to craft a "parameter" which alters the query
19:31 jberger but if you use a placeholder, the query is built before there are parameters passed to it
19:31 jberger so that isn't possible
19:32 Bean that makes a lot of sense! thank you thank you
19:33 jberger the one injection you tried only works if the query was susceptible to that injection
19:33 ramortegui Hi all, I'm trying to use mojolicious on heroku (following a video), but when I tried to deploy I get this error:  Can't locate object method "new" via package "Mojo::JSON",  Do I need to install a specific version of mojolicious or a particular package ?
19:33 jberger but in reality injections are usually designed per-query
19:33 jberger ramortegui: the Mojo::JSON package has changed quite a bit since that vide
19:33 jberger o
19:34 jberger there is no more OO api, just function
19:37 ramortegui mmm ok thanks jberger.  So the question will be if is there other way, or documentation to follow in order to run a sample  app on heroku?
19:38 jberger I don't recall what the video was doing exactly
19:38 jberger but the documentation for Mojo::JSON is fairly clear
19:38 jberger http://mojolicious.org/perldoc/Mojo/JSON
19:39 jberger the only potential difficulty is the distinction between to/from_json and encode/decode_json
19:39 jberger which is that the latter ones also deal with utf8 encodings
19:40 jberger meaning that the latter are good for application boundaries where the former are good for needing json formatting but for a string that stays inside the application (less common)
19:43 ramortegui thanks jberger, I'll read about it.
19:53 punter joined #mojo
20:16 disputin joined #mojo
20:27 leoj joined #mojo
20:31 cfedde joined #mojo
20:54 val40 joined #mojo
21:19 tchaves joined #mojo
21:51 gtodd Mojo version is 6.66
22:01 jberger indeed
22:01 jberger we didn't miss it :-P
22:22 val40 joined #mojo
22:25 zivester joined #mojo
22:57 disputin joined #mojo
23:03 disputin joined #mojo
23:10 _dave_ Did you miss the sacrificial ceremony? It was streamed via Twitch...
23:16 meshl joined #mojo
23:31 leoj joined #mojo
23:31 bpmedley https://engineering.semantics3.com/2016/06/15/a-perl-toolchain-for-building-micro-services-at-scale/  <-- has this been mentioned?
23:34 jberger it was, as was the HN thread about it (which stayed remarkably civil): https://news.ycombinator.com/item?id=11943634
23:37 jberger Grinnz: I'm curious why you used URI in Mojo::SQLite rather than Mojo::URL
23:37 jberger not complaining, just interested
23:38 Grinnz_ to support the file: and sqlite: schemas properly
23:42 pink_mist what in those doesn't Mojo::URL support properly? 0_o
23:43 Grinnz_ filenames don't map directly to file: URLs, URI::file takes care of that; and URI::db takes care of interpreting a sqlite: URL as a database name/filename
23:44 pink_mist filenames don't? do you have an example?
23:45 Grinnz_ a filename is interpreted according to the current operating system and turned into a file: URL
23:45 Grinnz_ file: URLs are the same across operating systems, filenames are not
23:46 pink_mist do you have an example? I'm not going to get what you're talking about otherwise I don't think
23:46 Grinnz_ it's been a while since I messed with all this
23:46 Grinnz_ the examples in https://metacpan.org/pod/Mojo::SQLite#from_string may help
23:48 disputin joined #mojo
23:50 pink_mist didn't think file:foo and file:/foo were valid, and I'd have expected file://foo to be relative
23:50 pink_mist guess that makes sense then
23:50 Grinnz_ if you have the filename C:\foo\bar.db, on windows that gets turned into file:///C:/foo/bar.db, or sqlite:C:%5Cfoo%5Cbar.db; on unix, it gets turned into file:///path/to/cwd/C:%5Cfoo%5Cbar.db or sqlite:C:%5Cfoo%5Cbar.db (also a relative path)
23:51 Grinnz_ er, the sqlite: one was less nuanced, since it's not OS dependent, I think
23:52 Grinnz_ (it's up to sqlite itself to interpret as a filename according to the OS)
23:54 Grinnz_ file://foo <-- foo is the hostname here, not part of the path
23:54 pink_mist your example says it's an absolute path
23:54 pink_mist to /foo
23:55 pink_mist oh no wait
23:55 Grinnz_ file://localhost/home/fred/data.db
23:55 pink_mist sorry
23:55 pink_mist yeah, missed the localhost bit :P
23:55 pink_mist should pay better attention =)
23:55 Grinnz_ because these are all local files, localhost is the only valid hostname, which makes a lot of variants redundant
23:56 Grinnz_ but I do have the example there using Mojo::URL with the sqlite scheme, because that generally "just works"
23:56 Grinnz_ since it's basically a pass-through

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary