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
   ([email protected])1> couch_server:get_js_engine().
   <<"quickjs">>
   ([email protected])2> config:set("couchdb", "js_engine", "spidermonkey").
   ok
   ([email protected])3> couch_server:get_js_engine().
   <<"spidermonkey">>
   ([email protected])4> config:set("couchdb", "js_engine", "wrong_engine").
   ok
   ([email protected])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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to