CouchDB
  1. CouchDB
  2. COUCHDB-354

Ungraceful behaviour if view returns a function

    Details

    • Type: Improvement Improvement
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JavaScript View Server
    • Labels:
      None
    • Environment:
      {"couchdb":"Welcome","version":"0.10.0a776990"}
    • Skill Level:
      Regular Contributors Level (Easy to Medium)

      Description

      If a typo in a view definition causes it to return a function instead of a normal value:

      • the view server crashes
      • you get a huge Erlang barf in the log with worrying messages like "OS process timed out" and "brutal kill"

      I got all this just by accidentally writing "vs.shift" instead of "vs.shift()"

      The fundamental problem is that a function cannot be serialised in toJSON, but the error message is not helpful:

      OS Process Log Message: Error converting object to JSON: TypeError: {Array:function (v) {var ... snip loads ... "Object"] is not a function

      When actually the problem is that the object I was trying to convert was a function

      I will attach some code which replicates this, and the barf generated.

      Of course this is entirely down to user error in an invalid map/reduce function. However there's already a clean error for 'undefined', maybe this could be done for 'function' too (or indeed any non-serialisable entity)

      1. test_reduce_barf.rb
        1 kB
        Brian Candler
      2. barf.log
        9 kB
        Brian Candler

        Activity

        Hide
        Brian Candler added a comment -

        Example where re-reduce function accidentally returns a function instead of an object

        Show
        Brian Candler added a comment - Example where re-reduce function accidentally returns a function instead of an object
        Hide
        Brian Candler added a comment -

        The resulting barf

        Show
        Brian Candler added a comment - The resulting barf
        Hide
        Brian Candler added a comment -

        ... and what's more confusing, this error can be in one view, but you get it when querying a completely different view (because all the views are built at once). So even if the view server is going to crash, it would be good to know which view it was building at the time.

        Show
        Brian Candler added a comment - ... and what's more confusing, this error can be in one view, but you get it when querying a completely different view (because all the views are built at once). So even if the view server is going to crash, it would be good to know which view it was building at the time.
        Hide
        Jan Lehnardt added a comment -

        no barfs in trunk.

        > ruby1.9 test_reduce_barf.rb

        reduce across all says:

        {"rows":[]}

        jan@dahlia ~/Downloads
        > curl http://127.0.0.1:5984/

        {"couchdb":"Welcome","version":"0.10.0a773842"}

        Apache CouchDB 0.10.0a773842 (LogLevel=debug) is starting.
        Configuration Settings ["/Users/jan/Work/couchdb/trunk/etc/couchdb/default_dev.ini",
        "/Users/jan/Work/couchdb/trunk/etc/couchdb/local_dev.ini"]:
        [couchdb] batch_save_interval="1000"
        [couchdb] batch_save_size="1000"
        [couchdb] database_dir="/Users/jan/Work/couchdb/trunk/tmp/lib"
        [couchdb] max_attachment_chunk_size="4294967296"
        [couchdb] max_dbs_open="100"
        [couchdb] max_document_size="4294967296"
        [couchdb] os_process_timeout="5000"
        [couchdb] util_driver_dir="/Users/jan/Work/couchdb/trunk/src/couchdb/.libs"
        [couchdb] view_index_dir="/Users/jan/Work/couchdb/trunk/tmp/lib"
        [daemons] batch_save="

        {couch_batch_save_sup, start_link, []}

        "
        [daemons] db_update_notifier="

        {couch_db_update_notifier_sup, start_link, []}

        "
        [daemons] external_manager="

        {couch_external_manager, start_link, []}

        "
        [daemons] httpd="

        {couch_httpd, start_link, []}

        "
        [daemons] query_servers="

        {couch_query_servers, start_link, []}

        "
        [daemons] stats_aggregator="

        {couch_stats_aggregator, start, []}

        "
        [daemons] stats_collector="

        {couch_stats_collector, start, []}

        "
        [daemons] view_manager="

        {couch_view, start_link, []}

        "
        [httpd] WWW-Authenticate="Basic realm=\"administrator\""
        [httpd] authentication_handler="

        {couch_httpd, default_authentication_handler}

        "
        [httpd] bind_address="127.0.0.1"
        [httpd] default_handler="

        {couch_httpd_db, handle_request}

        "
        [httpd] port="5984"
        [httpd_db_handlers] _changes="

        {couch_httpd_db, handle_changes_req}

        "
        [httpd_db_handlers] _compact="

        {couch_httpd_db, handle_compact_req}

        "
        [httpd_db_handlers] _design="

        {couch_httpd_db, handle_design_req}

        "
        [httpd_db_handlers] _temp_view="

        {couch_httpd_view, handle_temp_view_req}

        "
        [httpd_design_handlers] _list="

        {couch_httpd_show, handle_view_list_req}

        "
        [httpd_design_handlers] _show="

        {couch_httpd_show, handle_doc_show_req}

        "
        [httpd_design_handlers] _view="

        {couch_httpd_view, handle_view_req}

        "
        [httpd_global_handlers] /="

        {couch_httpd_misc_handlers, handle_welcome_req, <<\"Welcome\">>}

        "
        [httpd_global_handlers] _active_tasks="

        {couch_httpd_misc_handlers, handle_task_status_req}

        "
        [httpd_global_handlers] _all_dbs="

        {couch_httpd_misc_handlers, handle_all_dbs_req}

        "
        [httpd_global_handlers] _config="

        {couch_httpd_misc_handlers, handle_config_req}

        "
        [httpd_global_handlers] _log="

        {couch_httpd_misc_handlers, handle_log_req}

        "
        [httpd_global_handlers] _replicate="

        {couch_httpd_misc_handlers, handle_replicate_req}

        "
        [httpd_global_handlers] _restart="

        {couch_httpd_misc_handlers, handle_restart_req}

        "
        [httpd_global_handlers] _sleep="

        {couch_httpd_misc_handlers, handle_sleep_req}

        "
        [httpd_global_handlers] _stats="

        {couch_httpd_stats_handlers, handle_stats_req}

        "
        [httpd_global_handlers] _utils="

        {couch_httpd_misc_handlers, handle_utils_dir_req, \"/Users/jan/Work/couchdb/trunk/share/www\"}

        "
        [httpd_global_handlers] _uuids="

        {couch_httpd_misc_handlers, handle_uuids_req}

        "
        [httpd_global_handlers] favicon.ico="

        {couch_httpd_misc_handlers, handle_favicon_req, \"/Users/jan/Work/couchdb/trunk/share/www\"}

        "
        [log] file="/Users/jan/Work/couchdb/trunk/tmp/log/couch.log"
        [log] level="debug"
        [query_server_config] reduce_limit="true"
        [query_servers] javascript="/Users/jan/Work/couchdb/trunk/bin/couchjs_dev /Users/jan/Work/couchdb/trunk/share/server/main.js"
        Apache CouchDB has started. Time to relax.
        [info] [<0.1.0>] Apache CouchDB has started.
        [debug] [<0.52.0>] 'DELETE' /test

        {1,1}
        Headers: [{'Accept',"application/xml"},
        {'Accept-Encoding',"gzip, deflate"},
        {'Host',"127.0.0.1:5984"},
        {'User-Agent',"Ruby"}]
        [debug] [<0.52.0>] httpd 404 error response:
        {"error":"not_found","reason":"missing"}

        [info] [<0.52.0>] 127.0.0.1 - - 'DELETE' /test 404
        [debug] [<0.57.0>] 'PUT' /test {1,1}

        Headers: [

        {'Accept',"application/xml"},
        {'Accept-Encoding',"gzip, deflate"},
        {'Content-Length',"2"},
        {'Content-Type',"application/x-www-form-urlencoded"},
        {'Host',"127.0.0.1:5984"},
        {'User-Agent',"Ruby"}]
        [info] [<0.57.0>] 127.0.0.1 - - 'PUT' /test 201
        [debug] [<0.58.0>] 'POST' /test/_bulk_docs {1,1}
        Headers: [{'Accept',"application/xml"}

        ,

        {'Accept-Encoding',"gzip, deflate"},
        {'Content-Length',"1901"},
        {'Content-Type',"application/x-www-form-urlencoded"},
        {'Host',"127.0.0.1:5984"},
        {'User-Agent',"Ruby"}]
        [info] [<0.58.0>] 127.0.0.1 - - 'POST' /test/_bulk_docs 201
        [debug] [<0.67.0>] 'PUT' /test/_design/test {1,1}
        Headers: [{'Accept',"application/xml"},
        {'Accept-Encoding',"gzip, deflate"}

        ,

        {'Content-Length',"896"}

        ,

        {'Content-Type',"application/x-www-form-urlencoded"}

        ,

        {'Host',"127.0.0.1:5984"}

        ,

        {'User-Agent',"Ruby"}]
        [info] [<0.67.0>] 127.0.0.1 - - 'PUT' /test/_design/test 201
        [debug] [<0.68.0>] 'GET' /test/_design/test/_view/test {1,1}
        Headers: [{'Accept',"application/xml"},
        {'Accept-Encoding',"gzip, deflate"},
        {'Host',"127.0.0.1:5984"},
        {'User-Agent',"Ruby"}

        ]
        [debug] [<0.44.0>] Spawning new group server for view group _design/test in database test.
        [debug] [<0.70.0>] Reseting group index "_design/test" in db test
        [debug] [<0.68.0>] request_group

        {Pid, Seq} {<0.70.0>,151}
        [debug] [<0.68.0>] request_group {Pid, Seq}

        {<0.70.0>,151}

        [info] [<0.68.0>] 127.0.0.1 - - 'GET' /test/_design/test/_view/test 200
        [debug] [<0.69.0>] 'GET' /

        {1,1}

        Headers: [

        {'Accept',"*/*"}

        ,

        {'Host',"127.0.0.1:5984"}

        ,

        {'User-Agent',"curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3"}

        ]
        [info] [<0.69.0>] 127.0.0.1 - - 'GET' / 200

        Show
        Jan Lehnardt added a comment - no barfs in trunk. – > ruby1.9 test_reduce_barf.rb reduce across all says: {"rows":[]} jan@dahlia ~/Downloads > curl http://127.0.0.1:5984/ {"couchdb":"Welcome","version":"0.10.0a773842"} – Apache CouchDB 0.10.0a773842 (LogLevel=debug) is starting. Configuration Settings ["/Users/jan/Work/couchdb/trunk/etc/couchdb/default_dev.ini", "/Users/jan/Work/couchdb/trunk/etc/couchdb/local_dev.ini"]: [couchdb] batch_save_interval="1000" [couchdb] batch_save_size="1000" [couchdb] database_dir="/Users/jan/Work/couchdb/trunk/tmp/lib" [couchdb] max_attachment_chunk_size="4294967296" [couchdb] max_dbs_open="100" [couchdb] max_document_size="4294967296" [couchdb] os_process_timeout="5000" [couchdb] util_driver_dir="/Users/jan/Work/couchdb/trunk/src/couchdb/.libs" [couchdb] view_index_dir="/Users/jan/Work/couchdb/trunk/tmp/lib" [daemons] batch_save=" {couch_batch_save_sup, start_link, []} " [daemons] db_update_notifier=" {couch_db_update_notifier_sup, start_link, []} " [daemons] external_manager=" {couch_external_manager, start_link, []} " [daemons] httpd=" {couch_httpd, start_link, []} " [daemons] query_servers=" {couch_query_servers, start_link, []} " [daemons] stats_aggregator=" {couch_stats_aggregator, start, []} " [daemons] stats_collector=" {couch_stats_collector, start, []} " [daemons] view_manager=" {couch_view, start_link, []} " [httpd] WWW-Authenticate="Basic realm=\"administrator\"" [httpd] authentication_handler=" {couch_httpd, default_authentication_handler} " [httpd] bind_address="127.0.0.1" [httpd] default_handler=" {couch_httpd_db, handle_request} " [httpd] port="5984" [httpd_db_handlers] _changes=" {couch_httpd_db, handle_changes_req} " [httpd_db_handlers] _compact=" {couch_httpd_db, handle_compact_req} " [httpd_db_handlers] _design=" {couch_httpd_db, handle_design_req} " [httpd_db_handlers] _temp_view=" {couch_httpd_view, handle_temp_view_req} " [httpd_design_handlers] _list=" {couch_httpd_show, handle_view_list_req} " [httpd_design_handlers] _show=" {couch_httpd_show, handle_doc_show_req} " [httpd_design_handlers] _view=" {couch_httpd_view, handle_view_req} " [httpd_global_handlers] /=" {couch_httpd_misc_handlers, handle_welcome_req, <<\"Welcome\">>} " [httpd_global_handlers] _active_tasks=" {couch_httpd_misc_handlers, handle_task_status_req} " [httpd_global_handlers] _all_dbs=" {couch_httpd_misc_handlers, handle_all_dbs_req} " [httpd_global_handlers] _config=" {couch_httpd_misc_handlers, handle_config_req} " [httpd_global_handlers] _log=" {couch_httpd_misc_handlers, handle_log_req} " [httpd_global_handlers] _replicate=" {couch_httpd_misc_handlers, handle_replicate_req} " [httpd_global_handlers] _restart=" {couch_httpd_misc_handlers, handle_restart_req} " [httpd_global_handlers] _sleep=" {couch_httpd_misc_handlers, handle_sleep_req} " [httpd_global_handlers] _stats=" {couch_httpd_stats_handlers, handle_stats_req} " [httpd_global_handlers] _utils=" {couch_httpd_misc_handlers, handle_utils_dir_req, \"/Users/jan/Work/couchdb/trunk/share/www\"} " [httpd_global_handlers] _uuids=" {couch_httpd_misc_handlers, handle_uuids_req} " [httpd_global_handlers] favicon.ico=" {couch_httpd_misc_handlers, handle_favicon_req, \"/Users/jan/Work/couchdb/trunk/share/www\"} " [log] file="/Users/jan/Work/couchdb/trunk/tmp/log/couch.log" [log] level="debug" [query_server_config] reduce_limit="true" [query_servers] javascript="/Users/jan/Work/couchdb/trunk/bin/couchjs_dev /Users/jan/Work/couchdb/trunk/share/server/main.js" Apache CouchDB has started. Time to relax. [info] [<0.1.0>] Apache CouchDB has started. [debug] [<0.52.0>] 'DELETE' /test {1,1} Headers: [{'Accept',"application/xml"}, {'Accept-Encoding',"gzip, deflate"}, {'Host',"127.0.0.1:5984"}, {'User-Agent',"Ruby"}] [debug] [<0.52.0>] httpd 404 error response: {"error":"not_found","reason":"missing"} [info] [<0.52.0>] 127.0.0.1 - - 'DELETE' /test 404 [debug] [<0.57.0>] 'PUT' /test {1,1} Headers: [ {'Accept',"application/xml"}, {'Accept-Encoding',"gzip, deflate"}, {'Content-Length',"2"}, {'Content-Type',"application/x-www-form-urlencoded"}, {'Host',"127.0.0.1:5984"}, {'User-Agent',"Ruby"}] [info] [<0.57.0>] 127.0.0.1 - - 'PUT' /test 201 [debug] [<0.58.0>] 'POST' /test/_bulk_docs {1,1} Headers: [{'Accept',"application/xml"} , {'Accept-Encoding',"gzip, deflate"}, {'Content-Length',"1901"}, {'Content-Type',"application/x-www-form-urlencoded"}, {'Host',"127.0.0.1:5984"}, {'User-Agent',"Ruby"}] [info] [<0.58.0>] 127.0.0.1 - - 'POST' /test/_bulk_docs 201 [debug] [<0.67.0>] 'PUT' /test/_design/test {1,1} Headers: [{'Accept',"application/xml"}, {'Accept-Encoding',"gzip, deflate"} , {'Content-Length',"896"} , {'Content-Type',"application/x-www-form-urlencoded"} , {'Host',"127.0.0.1:5984"} , {'User-Agent',"Ruby"}] [info] [<0.67.0>] 127.0.0.1 - - 'PUT' /test/_design/test 201 [debug] [<0.68.0>] 'GET' /test/_design/test/_view/test {1,1} Headers: [{'Accept',"application/xml"}, {'Accept-Encoding',"gzip, deflate"}, {'Host',"127.0.0.1:5984"}, {'User-Agent',"Ruby"} ] [debug] [<0.44.0>] Spawning new group server for view group _design/test in database test. [debug] [<0.70.0>] Reseting group index "_design/test" in db test [debug] [<0.68.0>] request_group {Pid, Seq} {<0.70.0>,151} [debug] [<0.68.0>] request_group {Pid, Seq} {<0.70.0>,151} [info] [<0.68.0>] 127.0.0.1 - - 'GET' /test/_design/test/_view/test 200 [debug] [<0.69.0>] 'GET' / {1,1} Headers: [ {'Accept',"*/*"} , {'Host',"127.0.0.1:5984"} , {'User-Agent',"curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3"} ] [info] [<0.69.0>] 127.0.0.1 - - 'GET' / 200
        Hide
        Brian Candler added a comment -

        This is really odd: trunk still barfs for me. And what's especially odd is (a) your debug log doesn't show anything wrong with that Javascript at all, and (b) your reduce output is completely empty, not even 'key'=>null. Does all_docs show the documents? You're not running the eep-0018 branch?

        I get exactly the same:

        $ curl http://127.0.0.1:5984/

        {"couchdb":"Welcome","version":"0.10.0a777521"}

        $ ruby ~/test_reduce_barf.rb

        reduce across all says:
        /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:144:in `process_result': HTTP status code 500 (RestClient::RequestFailed)
        from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:106:in `transmit'
        from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
        from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:103:in `transmit'
        from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:36:in `execute_inner'
        from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:28:in `execute'
        from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:12:in `execute'
        from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient.rb:57:in `get'
        from /home/brian/test_reduce_barf.rb:56

        $ curl http://127.0.0.1:5984/_log

        {trap_exit,true}

        ,

        {status,running}

        ,

        {heap_size,987}

        ,

        {stack_size,23}

        ,

        {reductions,751}

        ],
        []]}}

        [Fri, 22 May 2009 13:53:41 GMT] [error] [<0.44.0>] {error_report,<0.22.0>,
        {<0.44.0>,supervisor_report,
        [{supervisor,{local,couch_secondary_services}},

        {errorContext,child_terminated}

        ,
        {reason,{os_process_error,"OS process timed out."}},
        {offender,[

        {pid,<0.45.0>}

        ,

        {name,view_manager}

        ,
        {mfa,{couch_view,start_link,[]}},

        {restart_type,permanent}

        ,

        {shutdown,brutal_kill}

        ,

        {child_type,worker}

        ]}]}}

        [Fri, 22 May 2009 13:53:41 GMT] [info] [<0.78.0>] 127.0.0.1 - - 'GET' /test/_design/test/_view/test 500

        [Fri, 22 May 2009 13:53:50 GMT] [info] [<0.79.0>] 127.0.0.1 - - 'GET' / 200

        So maybe it's something platform related. On this particular machine, I am running:

        • Ubuntu Jaunty
        • erlang 1:12.b.5-dfsg-2
        • libmozjs0d 1.8.1.16+nobinonly-0ubuntu1

        (erlang and spidermonkey are both out-of-the-box Ubuntu components)

        Show
        Brian Candler added a comment - This is really odd: trunk still barfs for me. And what's especially odd is (a) your debug log doesn't show anything wrong with that Javascript at all, and (b) your reduce output is completely empty, not even 'key'=>null. Does all_docs show the documents? You're not running the eep-0018 branch? I get exactly the same: $ curl http://127.0.0.1:5984/ {"couchdb":"Welcome","version":"0.10.0a777521"} $ ruby ~/test_reduce_barf.rb reduce across all says: /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:144:in `process_result': HTTP status code 500 (RestClient::RequestFailed) from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:106:in `transmit' from /usr/lib/ruby/1.8/net/http.rb:543:in `start' from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:103:in `transmit' from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:36:in `execute_inner' from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:28:in `execute' from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient/request.rb:12:in `execute' from /var/lib/gems/1.8/gems/rest-client-0.9.2/lib/restclient.rb:57:in `get' from /home/brian/test_reduce_barf.rb:56 $ curl http://127.0.0.1:5984/_log {trap_exit,true} , {status,running} , {heap_size,987} , {stack_size,23} , {reductions,751} ], []]}} [Fri, 22 May 2009 13:53:41 GMT] [error] [<0.44.0>] {error_report,<0.22.0>, {<0.44.0>,supervisor_report, [{supervisor,{local,couch_secondary_services}}, {errorContext,child_terminated} , {reason,{os_process_error,"OS process timed out."}}, {offender,[ {pid,<0.45.0>} , {name,view_manager} , {mfa,{couch_view,start_link,[]}}, {restart_type,permanent} , {shutdown,brutal_kill} , {child_type,worker} ]}]}} [Fri, 22 May 2009 13:53:41 GMT] [info] [<0.78.0>] 127.0.0.1 - - 'GET' /test/_design/test/_view/test 500 [Fri, 22 May 2009 13:53:50 GMT] [info] [<0.79.0>] 127.0.0.1 - - 'GET' / 200 So maybe it's something platform related. On this particular machine, I am running: Ubuntu Jaunty erlang 1:12.b.5-dfsg-2 libmozjs0d 1.8.1.16+nobinonly-0ubuntu1 (erlang and spidermonkey are both out-of-the-box Ubuntu components)
        Hide
        Jan Lehnardt added a comment -

        > * libmozjs0d 1.8.1.16+nobinonly-0ubuntu1
        ^^^^^^^^^^^^^^^^^ - I believe this to be a non-stable release. Can you please try with 1.7?

        Show
        Jan Lehnardt added a comment - > * libmozjs0d 1.8.1.16+nobinonly-0ubuntu1 ^^^^^^^^^^^^^^^^^ - I believe this to be a non-stable release. Can you please try with 1.7?
        Hide
        Brian Candler added a comment -

        It's the only version provided in both Ubuntu Hardy and Ubuntu Jaunty. It also works perfectly fine for me in general, and I don't think the problem is anything to do with the Javascript engine.

        Hidden in the barf you can see what the error is - it's caused by the toJSON function in main.js, which in skeleton form looks like this: it's a strange sort of case statement.

        return

        {'Array':f1, 'Boolean':f2, ...}

        [val.constructor.name](val);

        The problem is that if val is a function, val.constructor.name is 'Function' which is not defined in the object, so you are essentially calling undefined(val).

        You can get a rather better error by catching unexpected values, e.g. like this:

        — main.js.orig 2009-05-22 16:26:22.000000000 +0100
        +++ main.js 2009-05-22 16:32:05.000000000 +0100
        @@ -306,7 +306,7 @@
        if (typeof(val) == "xml")

        { // E4X support val = val.toXMLString(); }
        • return {
          + var handlers = {
          "Array": function(v)
          Unknown macro: { var buf = []; for (var i = 0; i < v.length; i++) { @@ -351,7 +351,11 @@ } return '"' + v + '"'; }
        • }[val != null ? val.constructor.name : "Object"](val);
          + }
          + var k = val != null ? val.constructor.name : "Object";
          + var h = handlers[k];
          + if (!h) { throw ("Cannot encode '" + k + "' value as JSON") }

          ;
          + return h(val);
          }

        function compileFunction(source) {

        But I still get a 'badmatch' crash:

          • Reason for termination ==
          • {{badmatch,<<"Cannot encode 'Function' value as JSON">>},
            [ {couch_query_servers,'-rereduce/3-fun-0-',3}

            ,

            {lists,zipwith,3}

            ,

            {couch_query_servers,rereduce,3}

            ,

            {couch_view_group,'-init_group/4-fun-0-',4}

            ,

            {couch_btree,'-write_node/3-lc$^0/1-0-',3}

            ,

            {couch_btree,write_node,3}

            ,

            {couch_btree,complete_root,2}

            ,

            {couch_btree,query_modify,4}

            ]}

        Given that you've closed this ticket a second time, I'll defer to your judgement that you do not think this should be fixed, and leave it closed.

        Show
        Brian Candler added a comment - It's the only version provided in both Ubuntu Hardy and Ubuntu Jaunty. It also works perfectly fine for me in general, and I don't think the problem is anything to do with the Javascript engine. Hidden in the barf you can see what the error is - it's caused by the toJSON function in main.js, which in skeleton form looks like this: it's a strange sort of case statement. return {'Array':f1, 'Boolean':f2, ...} [val.constructor.name] (val); The problem is that if val is a function, val.constructor.name is 'Function' which is not defined in the object, so you are essentially calling undefined(val). You can get a rather better error by catching unexpected values, e.g. like this: — main.js.orig 2009-05-22 16:26:22.000000000 +0100 +++ main.js 2009-05-22 16:32:05.000000000 +0100 @@ -306,7 +306,7 @@ if (typeof(val) == "xml") { // E4X support val = val.toXMLString(); } return { + var handlers = { "Array": function(v) Unknown macro: { var buf = []; for (var i = 0; i < v.length; i++) { @@ -351,7 +351,11 @@ } return '"' + v + '"'; } } [val != null ? val.constructor.name : "Object"] (val); + } + var k = val != null ? val.constructor.name : "Object"; + var h = handlers [k] ; + if (!h) { throw ("Cannot encode '" + k + "' value as JSON") } ; + return h(val); } function compileFunction(source) { But I still get a 'badmatch' crash: Reason for termination == {{badmatch,<<"Cannot encode 'Function' value as JSON">>}, [ {couch_query_servers,'-rereduce/3-fun-0-',3} , {lists,zipwith,3} , {couch_query_servers,rereduce,3} , {couch_view_group,'-init_group/4-fun-0-',4} , {couch_btree,'-write_node/3-lc$^0/1-0-',3} , {couch_btree,write_node,3} , {couch_btree,complete_root,2} , {couch_btree,query_modify,4} ]} Given that you've closed this ticket a second time, I'll defer to your judgement that you do not think this should be fixed, and leave it closed.
        Hide
        Jan Lehnardt added a comment -

        Oh hey by no means, keep opening things as you see fit

        The problem is that there's behaviour change between 1.7 and 1.8 and we currently only work with 1.7. Paul offered to get this fixed. Reopening the ticket so we don't forget.

        Thanks for the JS diff, too.

        Show
        Jan Lehnardt added a comment - Oh hey by no means, keep opening things as you see fit – The problem is that there's behaviour change between 1.7 and 1.8 and we currently only work with 1.7. Paul offered to get this fixed. Reopening the ticket so we don't forget. – Thanks for the JS diff, too.

          People

          • Assignee:
            Unassigned
            Reporter:
            Brian Candler
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development