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. barf.log
        9 kB
        Brian Candler
      2. test_reduce_barf.rb
        1 kB
        Brian Candler

        Activity

          People

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

            Dates

            • Created:
              Updated:

              Development