Commit 06c88fb
committed
fix(js): re-instate
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-L188deepFreeze() for all object freezing duties1 parent faa4fc8 commit 06c88fb
File tree
2 files changed
+15
-13
lines changed2 files changed
+15
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 47 | | |
52 | 48 | | |
53 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 119 | + | |
127 | 120 | | |
128 | 121 | | |
129 | 122 | | |
| |||
155 | 148 | | |
156 | 149 | | |
157 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
| |||
0 commit comments