Skip to content

Commit

Permalink
feat: removed "ready" sub handle usage to prevent retries on failure (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nbiton authored Apr 10, 2019
1 parent 658f816 commit 2bc4a82
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 9 deletions.
2 changes: 0 additions & 2 deletions imports/api/base/rest-resource-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default ({ collectionName, dataResolver, idResolver = defaultIdResolver }

// Checking if the user is authenticated
if (!subHandle.userId) {
subHandle.ready()
subHandle.error(new Meteor.Error({ message: 'Authentication required' }))
return false
}
Expand Down Expand Up @@ -101,7 +100,6 @@ export default ({ collectionName, dataResolver, idResolver = defaultIdResolver }
in an error:`,
err
)
subHandle.ready()
subHandle.error(new Meteor.Error({ message: 'REST API error', origError: err }))
})
subHandle.onStop(() => {
Expand Down
4 changes: 2 additions & 2 deletions imports/api/base/rest-resource-factory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if (Meteor.isServer) {
expect(context.added).to.have.been.calledThrice()
expect(context.ready).to.have.been.calledOnce()
})
it('should use the "ready" and "error" triggers if an API error has occurred', (done) => {
it('should use the "error" trigger if an API error has occurred', (done) => {
const context = {
userId: 2132,
error: sinon.spy(),
Expand All @@ -125,7 +125,7 @@ if (Meteor.isServer) {
publishFunc.call(context, 444)

process.nextTick(() => {
expect(context.ready).to.have.been.calledOnce()
// expect(context.ready).to.have.been.calledOnce()
expect(context.error).to.have.been.calledOnce()
done()
})
Expand Down
2 changes: 0 additions & 2 deletions imports/api/case-field-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const clientLocalFieldMapping = Object.assign({}, caseClientFieldMapping, { bug_
if (Meteor.isServer) {
Meteor.publish(`${collectionName}.fetchByName`, function (name) {
if (!this.userId) {
this.ready()
this.error(new Meteor.Error({ message: 'Authentication required' }))
return false
}
Expand All @@ -28,7 +27,6 @@ if (Meteor.isServer) {
this.ready()
} catch (e) {
logger.error('API error encountered', e, `${collectionName}.fetchByName`, this.userId)
this.ready()
this.error(new Meteor.Error({ message: 'API Error' }))
}
})
Expand Down
1 change: 0 additions & 1 deletion imports/api/case-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Meteor.methods({
if (Meteor.isServer) {
Meteor.publish(`${collectionName}.myUpdates`, function () {
if (!this.userId) {
this.ready()
this.error(new Meteor.Error('Must be logged in first'))
}
return CaseNotifications.find({
Expand Down
1 change: 0 additions & 1 deletion imports/api/custom-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const findOrCreateUser = email => {

const verifyUserLogin = handle => {
if (!handle.userId) {
handle.ready()
handle.error(new Meteor.Error({ message: 'Authentication required' }))
return false
}
Expand Down
1 change: 0 additions & 1 deletion imports/api/pending-invitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ if (Meteor.isServer) {
check(caseId, Number)

if (!this.userId) {
this.ready()
this.error('Unauthorized')
return
}
Expand Down

0 comments on commit 2bc4a82

Please sign in to comment.