jiahuili430 commented on code in PR #5329:
URL: https://github.com/apache/couchdb/pull/5329#discussion_r1824988606


##########
src/couch/src/couch_server.erl:
##########
@@ -92,7 +93,12 @@ get_stats() ->
     [{start_time, ?l2b(Time)}, {dbs_open, Open}].
 
 get_js_engine() ->
-    list_to_binary(config:get("couchdb", "js_engine", ?COUCHDB_JS_ENGINE)).
+    Engine = config:get("couchdb", "js_engine", ?COUCHDB_JS_ENGINE),
+    % If user misconfigured it by accident, don't crash, use defaults
+    case lists:member(Engine, ?AVAILABLE_JS_ENGINES) of
+        true -> list_to_binary(Engine);
+        false -> list_to_binary(?COUCHDB_JS_ENGINE)

Review Comment:
   It turns out that my `icu4c` was outdated and `make` could not compile the 
code correctly.
   
   ```bash
   $ brew reinstall icu4c@75
   $ ./dev/remsh
   (node1@127.0.0.1)1> couch_server:get_js_engine().
   <<"quickjs">>
   (node1@127.0.0.1)2> config:set("couchdb", "js_engine", "spidermonkey").
   ok
   (node1@127.0.0.1)3> couch_server:get_js_engine().
   <<"spidermonkey">>
   (node1@127.0.0.1)4> config:set("couchdb", "js_engine", "wrong_engine").
   ok
   (node1@127.0.0.1)5> couch_server:get_js_engine().
   <<"quickjs">>
   ```
   
   Works as expected, +1!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to