Open vjrj opened 6 years ago
I see that if (Meteor.user())
is used in server side publications.
I use prefer to use if (this.userId)
instead. Some link:
https://stackoverflow.com/questions/16532316/how-to-get-meteor-user-to-return-on-the-server-side
sample:
https://github.com/comunes/todos-contra-el-fuego-web/blob/1360f742f3ba44c60fe3fa904a6450d57713f291/imports/api/Users/server/publications.js#L18
I think that method userCount
in imports/api/server/methods.js
fails also because of this.
See also https://github.com/DemocracyEarth/sovereign/issues/267#issuecomment-380939793 for a similar userCount fail log.
With other words, probably setting Meteor.user()
to a const
fix this:
const user = Meteor.user()
if (user) {
so we don't call Meteor.user()
two times.
A related error but in client side trying to sign-up:
TypeError: Cannot read property 'username' of undefined
at _validateUsername(/app.js:19714:61)
at Signup.handleBlur(/app.js:8755:33)
at HTMLUnknownElement.boundFunc(/packages/modules.js:130200:9)
at HTMLUnknownElement.wrapped(/packages/flowkey_raven.js:601:21)
at Object.ReactErrorUtils.js.ReactErrorUtils.invokeGuardedCallback(/packages/modules.js:130206:16)
at executeDispatch(/packages/modules.js:129987:21)
at Object.executeDispatchesInOrder(/packages/modules.js:130010:5)
at executeDispatchesAndRelease(/packages/modules.js:129404:22)
at executeDispatchesAndReleaseTopLevel(/packages/modules.js:129415:10)
at Array.forEach(<anonymous>)
at forEachAccumulated(/packages/modules.js:130309:9)
at Object.processEventQueue(/packages/modules.js:129615:7)
at runEventQueueInBatch(/packages/modules.js:136665:18)
at Object.handleTopLevel [as _handleTopLevel](/packages/modules.js:136675:5)
at handleTopLevelImpl(/packages/modules.js:141650:24)
at ReactDefaultBatchingStrategyTransaction.perform(/packages/modules.js:132677:20)
at Object.batchedUpdates(/packages/modules.js:141565:26)
at Object.batchedUpdates(/packages/modules.js:131365:27)
at dispatchEvent(/packages/modules.js:141725:20)
at HTMLDocument.wrapped(/packages/flowkey_raven.js:601:21)
at Bc(<anonymous>:480:385)
at Object.apply.navigator(<anonymous>:486:48)
at apply.ELEMENT(<anonymous>:486:72)
at callFunction(<anonymous>:361:33)
at apply.ELEMENT(<anonymous>:371:23)
More detailed info (browser, etc): https://sentry.comunes.org/democracy-earth/ci-testing-results/issues/618/
That some issue reporting right there ! @vjrj
I think that this is already fixed
Reopening: Still the same error but in other part of the code:
20180511-17:37:07.333(2)? Exception from sub feed id 6RtPuvG6qWAWmm7Wq { stack: 'TypeError: Cannot read property \'username\' of undefined\n at _logUser (lib/const.js:9:16)\n at _views.latest.terms (lib/views.js:16:34)\n at _query (lib/views.js:300:22)\n at Subscription._handler (imports/api/server/publications.js:105:22)\n at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1768:12)\n at DDP._CurrentPublicationInvocation.withValue (packages/ddp-server/livedata_server.js:1043:15)\n at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:12)\n at Subscription._runHandler (packages/ddp-server/livedata_server.js:1041:51)\n at Subscription.subscriptionProto._runHandler (packages/mdg_meteor-apm-agent.js:2779:24)\n at Session._startSubscription (packages/ddp-server/livedata_server.js:859:9)\n at Session.sub (packages/ddp-server/livedata_server.js:625:12)\n at packages/mdg_meteor-apm-agent.js:2642:34\n at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:12)\n at Session.sessionProto.protocol_handlers.sub (packages/mdg_meteor-apm-agent.js:2641:44)\n at packages/ddp-server/livedata_server.js:559:43',
I think this has already been fixed since it had to do on how some of the publications returned empty values instead of an array or collection when using the app logged off. Let me know if it happens again @vjrj.
I still see some errors in latest builds, check this for instance: https://ci.comunes.org/job/sovereign/248/console
Exception while invoking method 'getUser' { stack: 'TypeError: Cannot read property \'_id\' of undefined\n
or this other log:
Exception while invoking method 'subsidizeUser' { stack: '[object Object]\n => awaited here:\n at Promise.await`
related with: https://github.com/DemocracyEarth/sovereign/issues/295
Yesterday I was studying the logs and code more in deep, I think that the problem is related to the way we create users using Meter.call
to sendVerificationLink
and subsidizeUser
.
I think we can avoid this using:
https://docs.meteor.com/api/accounts-multi.html#AccountsServer-onCreateUser
on server side, to send the verification link etc prior to user insert. Take into account that we know the user._id
in onCreateUser
:
The user argument is created on the server and contains a proposed user object with all the automatically generated fields required for the user to log in, including the _id.
so we can call subsidizeUser
etc only in server side safely.
Here a sample in other meteor project to send a welcome message (for instance) in onCreateUser
.
Other option is to use after insert hooks. Some discussion about this topic.
pinging @medied for this since he worked on that part of the code. I'll try to check it out when I find proper time then.
This is a Bug Report
:tophat: User registration fails sometimes
For bug reports:
fails with this error:
To register as a user correctly
The common testing configuration.
What stacktrace or error message from your provider did you see?
More info: https://ci.comunes.org/job/sovereign/78/console
Sovereign deployment where you found the issue: jenkins chimp testing
Browser & version: chrome headless 65.0.3325.181-0ubuntu0.