This is an automated email from the ASF dual-hosted git repository.
nickva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new ac042fbe6 Use errstr() instead of toSource() in nouveau js wrapper
ac042fbe6 is described below
commit ac042fbe6eaec3b1b60f41510eb8e17dc4b3b893
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Wed Apr 22 00:26:39 2026 -0400
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 8c75d4a25..474e94c87 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 304163f0a..0066ce372 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 888513fab..352270c22 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]