kokizzu / plv8js

Automatically exported from code.google.com/p/plv8js
Other
0 stars 0 forks source link

try/catch/return crashes postgres server #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

returning a value from a try/catch with a js error works as expected, however 
if the error is caused by postgres, returning a value crashes the server.  To 
reproduce, run the below example -- NOTE: it will crash postgres

CREATE OR REPLACE function plv8_dump() returns text language plv8 as
$JS$
   /* this works: returns: "error: oneBadFunc is not defined"
   try {
     oneBadFunc();
   } catch(e) {
     return "error: "+e.message;
   }
   */
   /* this brings down entire server */
   try {
     plv8.execute("SELECT * FROM null_table WHERE ",[8]);
   } catch(e) {
     // throw e;   //<-- does not crash
     return "error: "+e.message;
   }
$JS$;                  

What version of the product are you using? On what operating system?
postgres: 9.2.1, plv8 1.3.0devel

Also commented, but if the error is thrown in the catch postgres will not die

Original issue reported on code.google.com by t...@blit.com on 5 Jan 2013 at 7:51

GoogleCodeExporter commented 9 years ago
btw, if someone happens to run into this and is looking for a quick fix to move 
on, it seems that errors from js-land have properties, while errors bubbled up 
from postgres to js-land do not.  So as long as that hold true, in the catch 
block I do this before calling return:

if (Object.keys(e).length === 0) throw e;

It is working in all my tests, and prevents a bad query from causing pg to die

Original comment by t...@blit.com on 5 Jan 2013 at 7:59

GoogleCodeExporter commented 9 years ago
Hmm, it doesn't reproduce for me.  I'm using the latest git master, but I don't 
think it matters.  Which v8 version are you using?  Also let me know about OS.

Original comment by umi.tan...@gmail.com on 8 Jan 2013 at 6:19

GoogleCodeExporter commented 9 years ago
Closing as WontFix as the reproduction is not clear.  Please change the status 
again if you think otherwise.

Original comment by umi.tan...@gmail.com on 20 Feb 2013 at 8:18