-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
I recently upgraded from CouchDB 1.6.1 to 3.2.2, and took a moment to clean up my view functions. In the following view function, all I did was change the var to a let:
function (doc) {
let start;
if (
doc._id.indexOf("geometries_") === 0 &&
doc.features.length > 0 &&
doc.parentID
) {
start = doc.features[0].geometry.coordinates;
if (typeof start[0] !== "number") {
start = start[0];
}
emit([0, start[0]], doc.parentID);
emit([1, start[1]], doc.parentID);
}
}
As a result, GET requests to this view began responding with an error:
{
error: 'killed',
reason: '{gen_server,call,\n' +
' [couch_index_server,\n' +
' {get_index,\n' +
' {couch_mrview_index,\n' +
' {mrst,\n' +
' <<174,230,212,124,70,180,183,172,250,90,95,225,147,32,152,1>>,\n' +
' nil,undefined,\n' +
' <<"shards/00000000-7fffffff/events_near_me_c3sc8-7r.1663034046">>,\n' +
' <<"_design/geometries">>,<<"javascript">>,[],false,\n' +
' {[]},\n' +
' [{mrview,0,0,0,\n' +
' [<<"by_parent">>],\n' +
' [],\n' +
' <<"function (doc) {\\n if (doc._id.indexOf(\\"geometries_\\") === 0) {\\n if (doc.parentID) {\\n emit(doc.parentID);\\n }\\n }\\n }">>,\n' +
' nil,[]},\n' +
' {mrview,1,0,0,\n' +
' [<<"location">>],\n' +
' [],\n' +
' <<"function (doc) {\\n let start;\\n if (\\n doc._id.indexOf(\\"geometries_\\") === 0 &&\\n doc.features.length > 0 &&\\n doc.parentID\\n ) {\\n start = doc.features[0].geometry.coordinates;\\n if (typeof start[0] !== \\"number\\") {\\n start = start[0];\\n }\\n emit([0, start[0]], doc.parentID);\\n emit([1, start[1]], doc.parentID);\\n }\\n }">>,\n' +
' nil,[]}],\n' +
' nil,0,0,undefined,undefined,undefined,undefined,undefined,\n' +
' nil},\n' +
' <<"shards/00000000-7fffffff/events_near_me_c3sc8-7r.1663034046">>,\n' +
' <<174,230,212,124,70,180,183,172,250,90,95,225,147,32,152,1>>}},\n' +
' infinity]}',
ref: 2175788010
}
Reverting to the var solves the issue. I have tested this both with a native MacOS installation and the official Docker image, with identical results.
Calling GET /_node/_local/_versions gives:
{
"javascript_engine": {
"version": "78",
"name": "spidermonkey"
},
....
}
From what I could discern, SpiderMonkey v78 was used in Firefox v78, which certainly supported the let statement. So shouldn't let be supported in view functions? Have I missed something?
Metadata
Metadata
Assignees
Labels
No labels