Skip to content

Commit d6817c1

Browse files
Merge pull request #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/[email protected]
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 [email protected] simpl-schema chai
29+
meteor npm i --save [email protected] 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-
2-
accounts-password@2.3.4
1+
2+
accounts-password@2.4.0
33
44
55
6-
6+
77
88
99
10-
10+
1111
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
15-
16-
17-
18-
ddp-server@2.6.2
15+
16+
17+
18+
ddp-server@2.7.1
1919
2020
21-
21+
2222
2323
2424
2525
26-
27-
26+
27+
2828
2929
3030
31-
local-test:cultofcoders:redis-oplog@2.2.1
31+
local-test:cultofcoders:redis-oplog@2.3.0
3232
33-
33+
3434
35-
35+
3636
meteortesting:[email protected]
3737
meteortesting:[email protected]
38-
39-
40-
modules@0.19.0
38+
39+
40+
modules@0.20.0
4141
42-
42+
4343
4444
4545
4646
natestrauser:[email protected]
47-
npm-mongo@4.16.0
47+
npm-mongo@4.17.2
4848
4949
practicalmeteor:[email protected]
5050
5151
5252
5353
54-
54+
5555
5656
5757
5858
5959
6060
61-
61+
6262
63-
64-
63+
64+
65+
6566
66-
67+
6768
6869

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 [email protected] simpl-schema chai
35+
meteor npm i --save [email protected] 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 [email protected].
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)