Skip to content

Commit d6817c1

Browse files
Merge pull request cult-of-coders#412 from Meteor-Community-Packages/master
v2.3
2 parents 58ba426 + 6078c22 commit d6817c1

File tree

8 files changed

+63
-46
lines changed

8 files changed

+63
-46
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-22.04
88
strategy:
99
matrix:
10-
meteor: [1.12.2, 2.6.1, 2.7.3, 2.8.1, 2.12]
10+
meteor: [1.12.2, 2.8.1, 2.12, 2.15]
1111
redis-version: [4, 5, 6, 7]
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515

1616
- name: Start Redis
1717
uses: supercharge/redis-github-action@1.5.0
1818
with:
1919
redis-version: ${{ matrix.redis-version }}
2020

2121
- name: Setup Meteor
22-
uses: meteorengineer/setup-meteor@v1
22+
uses: meteorengineer/setup-meteor@v2
2323
with:
2424
meteor-release: ${{ matrix.meteor }}
2525
- name: Setup tests
2626
run: |
2727
meteor create --release ${{ matrix.meteor }} --bare test
2828
cd test
29-
meteor npm i --save puppeteer@1.18.1 simpl-schema chai
29+
meteor npm i --save puppeteer@1.18.1 simpl-schema@1.13.1 chai@4
3030
- name: Test
3131
working-directory: ./test
3232
run: METEOR_PACKAGE_DIRS="../" TEST_BROWSER_DRIVER=puppeteer meteor test-packages --raw-logs --once --driver-package meteortesting:mocha ../

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ npm-debug.log
44
.idea/
55

66
test/
7+
node_modules/

.versions

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,69 @@
1-
accounts-base@2.2.8
2-
accounts-password@2.3.4
1+
accounts-base@2.2.11
2+
accounts-password@2.4.0
33
alanning:roles@3.5.1
44
aldeed:collection2@3.0.6
55
allow-deny@1.1.1
6-
babel-compiler@7.10.4
6+
babel-compiler@7.10.5
77
babel-runtime@1.5.1
88
base64@1.0.12
99
binary-heap@1.0.11
10-
boilerplate-generator@1.7.1
10+
boilerplate-generator@1.7.2
1111
callback-hook@1.5.1
12-
check@1.3.2
13-
cultofcoders:redis-oplog@2.2.1
12+
check@1.4.1
13+
cultofcoders:redis-oplog@2.3.0
1414
ddp@1.4.1
15-
ddp-client@2.6.1
16-
ddp-common@1.4.0
17-
ddp-rate-limiter@1.2.0
18-
ddp-server@2.6.2
15+
ddp-client@2.6.2
16+
ddp-common@1.4.1
17+
ddp-rate-limiter@1.2.1
18+
ddp-server@2.7.1
1919
diff-sequence@1.1.2
2020
dynamic-import@0.7.3
21-
ecmascript@0.16.7
21+
ecmascript@0.16.8
2222
ecmascript-runtime@0.8.1
2323
ecmascript-runtime-client@0.12.1
2424
ecmascript-runtime-server@0.11.0
2525
ejson@1.1.3
26-
email@2.2.5
27-
fetch@0.1.3
26+
email@2.2.6
27+
fetch@0.1.4
2828
geojson-utils@1.0.11
2929
id-map@1.1.1
3030
inter-process-messaging@0.1.1
31-
local-test:cultofcoders:redis-oplog@2.2.1
31+
local-test:cultofcoders:redis-oplog@2.3.0
3232
localstorage@1.2.0
33-
logging@1.3.2
33+
logging@1.3.4
3434
matb33:collection-hooks@1.1.4
35-
meteor@1.11.3
35+
meteor@1.11.5
3636
meteortesting:browser-tests@0.1.2
3737
meteortesting:mocha@0.4.4
38-
minimongo@1.9.3
39-
modern-browsers@0.1.9
40-
modules@0.19.0
38+
minimongo@1.9.4
39+
modern-browsers@0.1.10
40+
modules@0.20.0
4141
modules-runtime@0.13.1
42-
mongo@1.16.7
42+
mongo@1.16.10
4343
mongo-decimal@0.1.3
4444
mongo-dev-server@1.1.0
4545
mongo-id@1.0.8
4646
natestrauser:publish-performant-counts@0.1.2
47-
npm-mongo@4.16.0
47+
npm-mongo@4.17.2
4848
ordered-dict@1.1.0
4949
practicalmeteor:mocha-core@1.0.1
5050
promise@0.12.2
5151
raix:eventemitter@0.1.3
5252
random@1.2.1
5353
rate-limit@1.1.1
54-
react-fast-refresh@0.2.7
54+
react-fast-refresh@0.2.8
5555
reactive-var@1.0.12
5656
reload@1.3.1
5757
retry@1.1.0
5858
reywood:publish-composite@1.7.3
5959
routepolicy@1.1.1
6060
sha@1.0.9
61-
socket-stream-client@0.5.1
61+
socket-stream-client@0.5.2
6262
tmeasday:check-npm-versions@0.3.2
63-
tracker@1.3.2
64-
underscore@1.0.13
63+
tracker@1.3.3
64+
typescript@4.9.5
65+
underscore@1.6.1
6566
url@1.3.2
66-
webapp@1.13.5
67+
webapp@1.13.8
6768
webapp-hashing@1.1.1
6869
zodern:types@1.0.9

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## CHANGELOG
22

3+
### 2.3.0
4+
5+
- perf: reduce GC pressure by avoiding EJSON.clone [PR 14](https://github.com/Meteor-Community-Packages/redis-oplog/pull/14) by [@alisnic](https://github.com/alisnic)
6+
37
### 2.2.1
48

59
- Update `alanning:roles` to v3.5.1

CONTRIBUTING.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
First, thank you for considering contributing to redis-oplog! It's people like you that make the open source community such a great community! 😊
66

7-
We welcome any type of contribution, not only code. You can help with
7+
We welcome any type of contribution, not only code. You can help with
8+
89
- **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open)
910
- **Marketing**: writing blog posts, howto's, printing stickers, ...
1011
- **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
@@ -13,7 +14,7 @@ We welcome any type of contribution, not only code. You can help with
1314

1415
## Your First Contribution
1516

16-
Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
17+
Working on your first Pull Request? You can learn how from this _free_ series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
1718

1819
## Submitting code
1920

@@ -26,14 +27,16 @@ It is also always helpful to have some context for your pull request. What was t
2627

2728
## Running Tests
2829

29-
### Setup
30+
### Setup
31+
3032
```
3133
meteor create --release 1.12.2 --bare test
3234
cd test
33-
meteor npm i --save puppeteer@1.18.1 simpl-schema chai
35+
meteor npm i --save puppeteer@1.18.1 simpl-schema chai@4
3436
```
3537

3638
### Start Tests
39+
3740
```
3841
METEOR_PACKAGE_DIRS="../" TEST_BROWSER_DRIVER=puppeteer meteor test-packages --raw-logs --once --driver-package meteortesting:mocha ../
3942
```
@@ -55,14 +58,12 @@ You can also reach us at hello@redis-oplog.opencollective.com.
5558
Thank you to all the people who have already contributed to redis-oplog!
5659
<a href="graphs/contributors"><img src="https://opencollective.com/redis-oplog/contributors.svg?width=890" /></a>
5760

58-
5961
### Backers
6062

6163
Thank you to all our backers! [[Become a backer](https://opencollective.com/redis-oplog#backer)]
6264

6365
<a href="https://opencollective.com/redis-oplog#backers" target="_blank"><img src="https://opencollective.com/redis-oplog/backers.svg?width=890"></a>
6466

65-
6667
### Sponsors
6768

6869
Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/redis-oplog#sponsor))

lib/cache/ObservableCollection.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,12 @@ export default class ObservableCollection {
196196
* @param safe {Boolean} If this is set to true, it assumes that the object is cleaned
197197
*/
198198
add(doc, safe = false) {
199-
doc = EJSON.clone(doc);
200-
201199
if (!safe) {
202200
if (this.fieldsArray) {
201+
// projection function clones the document already.
203202
doc = this.projectFieldsOnDoc(doc);
203+
} else {
204+
doc = EJSON.clone(doc);
204205
}
205206
}
206207

lib/mongo/ObserveMultiplex.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ export function ObserveMultiplexer(options) {
4141
});
4242
}
4343

44+
function strictFreeze(obj) {
45+
return new Proxy(obj, {
46+
set() {
47+
throw new Error('Cannot mutate a frozen object');
48+
}
49+
});
50+
}
51+
const freezeObject = Meteor.isProduction ? Object.freeze : strictFreeze
52+
4453
Object.assign(ObserveMultiplexer.prototype, {
4554
addHandleAndSendInitialAdds: function(handle) {
4655
var self = this;
@@ -213,24 +222,25 @@ Object.assign(ObserveMultiplexer.prototype, {
213222
// can continue until these are done. (But we do have to be careful to not
214223
// use a handle that got removed, because removeHandle does not use the
215224
// queue; thus, we iterate over an array of keys that we control.)
225+
const safeArgs = freezeObject(args);
226+
216227
Object.keys(self._handles).forEach(function(handleId) {
217228
var handle = self._handles && self._handles[handleId];
218229
if (!handle) return;
219230
var callback = handle['_' + callbackName];
220-
// clone arguments so that callbacks can mutate their arguments
221231

222232
// We silence out removed exceptions
223233
if (callback === 'removed') {
224234
try {
225-
callback.apply(null, EJSON.clone(args));
235+
callback.apply(null, safeArgs);
226236
} catch (e) {
227237
// Supressing `removed non-existent exceptions`
228238
if (!isRemovedNonExistent(e)) {
229239
throw e;
230240
}
231241
}
232242
} else {
233-
callback && callback.apply(null, EJSON.clone(args));
243+
callback && callback.apply(null, safeArgs);
234244
}
235245
});
236246
});
@@ -250,8 +260,7 @@ Object.assign(ObserveMultiplexer.prototype, {
250260
self._cache.docs.forEach(function(doc, id) {
251261
if (!_.has(self._handles, handle._id))
252262
throw Error('handle got removed before sending initial adds!');
253-
var fields = EJSON.clone(doc);
254-
delete fields._id;
263+
const { _id, ...fields } = doc
255264
if (self._ordered) add(id, fields, null);
256265
// we're going in order, so add at end
257266
else add(id, fields);

package.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package.describe({
22
name: 'cultofcoders:redis-oplog',
3-
version: '2.2.1',
3+
version: '2.3.0',
44
// Brief, one-line summary of the package.
55
summary: "Replacement for Meteor's MongoDB oplog implementation",
66
// URL to the Git repository containing the source code for this package.
@@ -17,7 +17,7 @@ Npm.depends({
1717
});
1818

1919
Package.onUse(function(api) {
20-
api.versionsFrom(['1.12.2', '2.8.1', '2.12']);
20+
api.versionsFrom(['1.12.2', '2.8.1', '2.13', '2.15', '2.16']);
2121
api.use([
2222
'underscore',
2323
'ecmascript',

0 commit comments

Comments
 (0)