{"action":"created","issue":{"url":"https://api.github.com/repos/plv8/plv8/issues/124","labels_url":"https://api.github.com/repos/plv8/plv8/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/plv8/plv8/issues/124/comments","events_url":"https://api.github.com/repos/plv8/plv8/issues/124/events","html_url":"https://github.com/plv8/plv8/issues/124","id":86093965,"number":124,"title":"Cannot call method 'elog' of null","user":{"login":"apiel","id":5873198,"avatar_url":"https://avatars.githubusercontent.com/u/5873198?v=3","gravatar_id":"","url":"https://api.github.com/users/apiel","html_url":"https://github.com/apiel","followers_url":"https://api.github.com/users/apiel/followers","following_url":"https://api.github.com/users/apiel/following{/other_user}","gists_url":"https://api.github.com/users/apiel/gists{/gist_id}","starred_url":"https://api.github.com/users/apiel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiel/subscriptions","organizations_url":"https://api.github.com/users/apiel/orgs","repos_url":"https://api.github.com/users/apiel/repos","events_url":"https://api.github.com/users/apiel/events{/privacy}","received_events_url":"https://api.github.com/users/apiel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-08T09:07:37Z","updated_at":"2015-06-19T03:03:11Z","closed_at":null,"body":"I got the following error: TypeError: Cannot call method 'elog' of null\r\n\r\nThis is my function:\r\n\r\n    create or replace function\r\n    js(src text, input json) returns json as $$\r\n      plv8.elog(NOTICE, 'test');\r\n      //--plv8 = null; // previously this was uncommented, since then, commented or not the plv8 is null. The goal was to deactivate the access to plv8 functions inside the eval\r\n      var evalRes = eval('var output=null; ' + src + '; output;');\r\n      return JSON.stringify(evalRes);\r\n    $$ LANGUAGE plv8;\r\n\r\n    select js('var a = input.test; var output = []; for(k in a) { output.push(10+a[k]); };', '{\"test\": [1,2,3]}'::json)\r\n"},"comment":{"url":"https://api.github.com/repos/plv8/plv8/issues/comments/113353440","html_url":"https://github.com/plv8/plv8/issues/124#issuecomment-113353440","issue_url":"https://api.github.com/repos/plv8/plv8/issues/124","id":113353440,"user":{"login":"schwebke","id":6435375,"avatar_url":"https://avatars.githubusercontent.com/u/6435375?v=3","gravatar_id":"","url":"https://api.github.com/users/schwebke","html_url":"https://github.com/schwebke","followers_url":"https://api.github.com/users/schwebke/followers","following_url":"https://api.github.com/users/schwebke/following{/other_user}","gists_url":"https://api.github.com/users/schwebke/gists{/gist_id}","starred_url":"https://api.github.com/users/schwebke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwebke/subscriptions","organizations_url":"https://api.github.com/users/schwebke/orgs","repos_url":"https://api.github.com/users/schwebke/repos","events_url":"https://api.github.com/users/schwebke/events{/privacy}","received_events_url":"https://api.github.com/users/schwebke/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T03:03:11Z","updated_at":"2015-06-19T03:03:11Z","body":"A restart of the backend should be enough (disconnect, reconnect)  to get a newly initialized v8 context. \r\n\r\nYou could place your eval in an anonymous function which contains a local plv8 var set to null. But I would propose a different approach - try to avoid eval, especially if the data evaled comes from an untrusted source. "}}