-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
LiveQueryEvent Error Logging Improvements #6951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
18dc84b
a76b7f0
968de7d
2510b66
fae8223
fe2812d
c2368cd
9b0face
d51a3f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,7 @@ class ParseLiveQueryServer { | |
// Check CLP | ||
const op = this._getCLPOperation(subscription.query); | ||
let res = {}; | ||
let aclError = true; | ||
this._matchesCLP( | ||
classLevelPermissions, | ||
message.currentParseObject, | ||
|
@@ -175,26 +176,38 @@ class ParseLiveQueryServer { | |
if (!isMatched) { | ||
return null; | ||
} | ||
aclError = false; | ||
res = { | ||
event: 'Delete', | ||
sessionToken: client.sessionToken, | ||
object: deletedParseObject, | ||
clients: this.clients.size, | ||
subscriptions: this.subscriptions.size, | ||
useMasterKey: client.hasMasterKey, | ||
installationId: client.installationId | ||
installationId: client.installationId, | ||
sendEvent: true, | ||
}; | ||
return maybeRunAfterEventTrigger('afterEvent', className, res); | ||
}) | ||
.then(() => { | ||
if (!res.sendEvent) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is in relation to preventing events from firing, which was previously achieved by throwing in the trigger. Setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry @dplewis, I'm not sure what the issue is, what would you like me to change? 😊 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throwing an error handles events from firing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, no worries. I added For example, only passing LQ update on "foo" change:
Would log on every single LQ event for TestObject, and pass a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see |
||
return; | ||
} | ||
if (res.object && typeof res.object.toJSON === 'function') { | ||
deletedParseObject = res.object.toJSON(); | ||
deletedParseObject.className = className; | ||
} | ||
client.pushDelete(requestId, deletedParseObject); | ||
}) | ||
.catch(error => { | ||
logger.error('Matching ACL error : ', error); | ||
if (aclError) { | ||
dblythy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logger.error('Matching ACL error : ', error); | ||
} else { | ||
logger.error( | ||
`Failed running afterLiveQueryEvent for event ${res.event} with session ${res.sessionToken} with:\n Error: ` + | ||
dblythy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
JSON.stringify(error) | ||
); | ||
} | ||
}); | ||
} | ||
} | ||
|
@@ -262,6 +275,7 @@ class ParseLiveQueryServer { | |
// subscription, we do not need to check ACL | ||
let currentACLCheckingPromise; | ||
let res = {}; | ||
let aclError = true; | ||
if (!isCurrentSubscriptionMatched) { | ||
currentACLCheckingPromise = Promise.resolve(false); | ||
} else { | ||
|
@@ -297,7 +311,7 @@ class ParseLiveQueryServer { | |
isCurrentMatched, | ||
subscription.hash | ||
); | ||
|
||
aclError = false; | ||
// Decide event type | ||
let type; | ||
if (isOriginalMatched && isCurrentMatched) { | ||
|
@@ -322,12 +336,16 @@ class ParseLiveQueryServer { | |
clients: this.clients.size, | ||
subscriptions: this.subscriptions.size, | ||
useMasterKey: client.hasMasterKey, | ||
installationId: client.installationId | ||
installationId: client.installationId, | ||
sendEvent: true, | ||
}; | ||
return maybeRunAfterEventTrigger('afterEvent', className, res); | ||
}) | ||
.then( | ||
() => { | ||
if (!res.sendEvent) { | ||
return; | ||
} | ||
if (res.object && typeof res.object.toJSON === 'function') { | ||
currentParseObject = res.object.toJSON(); | ||
currentParseObject.className = | ||
|
@@ -349,7 +367,14 @@ class ParseLiveQueryServer { | |
} | ||
}, | ||
error => { | ||
logger.error('Matching ACL error : ', error); | ||
if (aclError) { | ||
logger.error('Matching ACL error : ', error); | ||
} else { | ||
logger.error( | ||
`Failed running afterLiveQueryEvent for event ${res.event} with session ${res.sessionToken} with:\n Error: ` + | ||
JSON.stringify(error) | ||
); | ||
} | ||
} | ||
); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.