Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit ca1dca0

Browse files
committed
revert to using a simple shallowCopy for ops, since selectively copying is a breakign change if you've added new fields in middleware
1 parent 9effa65 commit ca1dca0

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/agent.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,7 @@ Agent.prototype._onOp = function(collection, id, op) {
172172
// before calling into projection and middleware code
173173
var agent = this;
174174
process.nextTick(function() {
175-
var copy = shallowCopyOp(op);
176-
if (!copy) {
177-
logger.error('Op emitted from subscription failed to copy', collection, id, op);
178-
return;
179-
}
175+
var copy = shallowCopy(op);
180176
agent.backend.sanitizeOp(agent, collection, id, copy, function(err) {
181177
if (err) {
182178
logger.error('Error sanitizing op emitted from subscription', collection, id, copy, err);
@@ -640,11 +636,12 @@ function createClientOp(request, clientId) {
640636
undefined;
641637
}
642638

643-
function shallowCopyOp(op) {
644-
return (op.op) ? new EditOp(op.src, op.seq, op.v, op.op, op.c, op.d, op.m) :
645-
(op.create) ? new CreateOp(op.src, op.seq, op.v, op.create, op.c, op.d, op.m) :
646-
(op.del) ? new DeleteOp(op.src, op.seq, op.v, op.del, op.c, op.d, op.m) :
647-
undefined;
639+
function shallowCopy(object) {
640+
var out = {};
641+
for (var key in object) {
642+
out[key] = object[key];
643+
}
644+
return out;
648645
}
649646

650647
function CreateOp(src, seq, v, create, c, d, m) {

0 commit comments

Comments
 (0)