From 357edebf84e1639cc216e514cbc1a4c05164a847 Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Wed, 22 Apr 2026 00:26:39 -0400 Subject: [PATCH] Use errstr() instead of toSource() in nouveau js wrapper `toSource()` is a Spidermonkey special, use our `errstr()` warpper function which checks if `toSource()` is available, and if not, it runs `toString()` instead --- share/server/nouveau.js | 2 +- test/elixir/test/config/nouveau.elixir | 1 + test/elixir/test/nouveau_test.exs | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/share/server/nouveau.js b/share/server/nouveau.js index 8c75d4a2502..474e94c874b 100644 --- a/share/server/nouveau.js +++ b/share/server/nouveau.js @@ -20,7 +20,7 @@ var Nouveau = (function () { } else if (err[0] == "fatal") { throw (err); } - var message = "function raised exception " + err.toSource(); + var message = "function raised exception " + errstr(err); if (doc) message += " with doc._id " + doc._id; log(message); }; diff --git a/test/elixir/test/config/nouveau.elixir b/test/elixir/test/config/nouveau.elixir index 304163f0a12..0066ce372e8 100644 --- a/test/elixir/test/config/nouveau.elixir +++ b/test/elixir/test/config/nouveau.elixir @@ -31,6 +31,7 @@ "purge with conflicts", "index same field with different field types", "index not found", + "index function throws", "meta", "stale search" ] diff --git a/test/elixir/test/nouveau_test.exs b/test/elixir/test/nouveau_test.exs index 888513fabdc..352270c2251 100644 --- a/test/elixir/test/nouveau_test.exs +++ b/test/elixir/test/nouveau_test.exs @@ -704,6 +704,30 @@ defmodule NouveauTest do assert_status_code(resp, 404) end + @tag :with_db + test "index function throws", context do + db_name = context[:db_name] + create_search_docs(db_name) + ddoc = %{ + nouveau: %{ + bar: %{ + default_analyzer: "standard", + index: """ + function (doc) { + throw(new Error("some error")); + index("string", "foo", doc.foo, {store: true}); + } + """ + } + } + } + create_ddoc(db_name, ddoc) + url = "/#{db_name}/_design/foo/_nouveau/bar" + resp = Couch.post(url, body: %{q: "foo:bar", include_docs: true}) + assert_status_code(resp, 200) + assert resp.body["hits"] == [] + end + @tag :with_db test "meta", context do db_name = context[:db_name]