You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(js): re-instate deepFreeze() for all object freezing duties
Prior to landing SpiderMonkey 102+ we relied on a global
`seal()` function that we defined in our custom `couchjs`
C/C++ code.
SM 102+ no longer exposes the API needed to implement
this, but the JS standard also includes a userspace
`Object.freeze()` method we can use.
Our initial implementation of SM 102+ support introduced[1]
a global `deepFreeze()` function that relied on `Reflect
.ownKeys()` which is not available in SpiderMonkey 1.8.5,
but all later ones we support.
To fix the build for SM 1.8.5, we partly reverted[2] the use
of `deepFreeze()`, but we missed a few spots in `main.js`
where we seal our own new globals like `Couch`[3].
This commit reinstates the use of `deepFreeze()` everywhere
and adds a safe fallback inside `deepFreeze()` to do the
right thing for SM 1.8.5 and > 1.8.5.
Tested on macOS with SM 128:
```
> ./src/couch/priv/couchjs -V
couchjs - Apache CouchDB 3.4.2-70fc2cc-dirty (SpiderMonkey 128.6.0)
[...]
> ./src/couch/priv/couchjs share/server/main.js
["reset"]
true
```
And Linux with SpiderMonkey 1.8.5:
```
> src/couch/priv/couchjs -V
couchjs - Apache CouchDB 3.4.2-121ac7c-dirty (SpiderMonkey 1.8.5)
[...]
> src/couch/priv/couchjs share/server/main.js
["reset"]
true
```
[1]: https://github.com/apache/couchdb/pull/5321/files#diff-71d0f32fee8a14f6a8d1775801cbb1851784c7050d844d2938d8fb8d71ecafe0R151
[2]: https://github.com/apache/couchdb/pull/5364/files#diff-71d0f32fee8a14f6a8d1775801cbb1851784c7050d844d2938d8fb8d71ecafe0R119
[3]: https://github.com/apache/couchdb/blob/main/share/server/loop.js#L180-L188
0 commit comments