Skip to content
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

Client Accounts.forgotPassword and .verifyEmail pass error in callback #7117

Closed
wants to merge 10 commits into from

Conversation

laosb
Copy link
Contributor

@laosb laosb commented May 25, 2016

Issue #5664
Previous PR #5681

This rebased @mishavee 's work. Thank you @mishavee !

@laosb
Copy link
Contributor Author

laosb commented May 25, 2016

Failing this:

C: tinytest - passwords - changing passwords : !!!!!!!!! FAIL !!!!!!!!!!!
TypeError: 'undefined' is not a function (evaluating 'callback(new Meteor.Error(400, "Password may not be empty"))')
    at http://localhost:4096/packages/accounts-password.js?hash=862511339ab24b4e1e7ce2ff8c7c7eb124812a89:190
    at http://localhost:4096/packages/local-test_accounts-password.js?hash=cfdd62289298c8f1242c7288d79099ae3ba32d46:405
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:273
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:260
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:237
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:221
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:281
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:260
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:237
    at http://localhost:4096/packages/test-helpers.js?hash=be3b6e8a6205a0152f0b4544ad2896638c07334e:214
    at http://localhost:4096/packages/accounts-password.js?hash=862511339ab24b4e1e7ce2ff8c7c7eb124812a89:215
    at http://localhost:4096/packages/meteor.js?hash=ed600264974381dc7fe10e24064e3d8c8a8eaa14:1105
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:3541
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:3561
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:4677
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:3369
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:2736
    at http://localhost:4096/packages/underscore.js?hash=27b3d669b418de8577518760446467e6ff429b1e:152
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:2737
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:175
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:1160
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:1218
    at http://localhost:4096/packages/ddp-client.js?hash=40a6742de1fccb42fc4e71f0eb5349f2df33c3c8:1365

@laosb
Copy link
Contributor Author

laosb commented May 25, 2016

My fault. Rebuilding.

@tmeasday tmeasday changed the title Rebase #5681. Client Accounts.forgotPassword and .verifyEmail pass error in callback May 25, 2016
@laosb
Copy link
Contributor Author

laosb commented May 26, 2016

Added in History.md.

@laosb
Copy link
Contributor Author

laosb commented May 28, 2016

Pinging @stubailo who reviewed the old PR.

@rafa-munoz
Copy link

Needs rebasing

@laosb
Copy link
Contributor Author

laosb commented Jun 3, 2016

Yeah, will do this weekend.

@laosb
Copy link
Contributor Author

laosb commented Jun 6, 2016

God slow Internet connection... Will try if I have a good connection.
Receiving objects: 16% (24449/148970), 11.30 MiB | 0 bytes/s

@benjamn
Copy link
Contributor

benjamn commented Jun 7, 2016

I would feel much better about these changes if we continued throwing the exception when there is no callback, rather than silently ignoring it.

@tmeasday
Copy link
Contributor

tmeasday commented Jun 7, 2016

@laosb to follow up on @benjamn's comment: although this is a well established pattern in this file, it seems really wrong to silently return from these functions when the OPTIONAL callback is not provided and the arguments are incorrect.

Can we please add something to this file like

reportError(error, callback) {
   if (callback) {
     callback(error);
   } else {
     throw error;
   }
}

And replace all the instances of

callback && callback(...);
return;

With

return reportError(callback, ...);

@tmeasday tmeasday self-assigned this Jun 7, 2016
@laosb
Copy link
Contributor Author

laosb commented Jun 9, 2016

Oh yeah of course.

@tmeasday
Copy link
Contributor

@laosb were you planning on looking at this?

@laosb
Copy link
Contributor Author

laosb commented Jul 1, 2016

@tmeasday Sorry for the delay! Tests running.

@tmeasday
Copy link
Contributor

tmeasday commented Jul 1, 2016

No problem @laosb !

@laosb
Copy link
Contributor Author

laosb commented Jul 1, 2016

My fault of copy&pasting. But the tests shouldn't hang on running when there is a error?
image

@laosb
Copy link
Contributor Author

laosb commented Jul 1, 2016

@tmeasday Code fixed but seems that tests are not suitable for this update. Can you give me some hints on modifying tests?

@@ -118,8 +125,7 @@ Accounts.createUser = function (options, callback) {
if (typeof options.password !== 'string')
throw new Error("options.password must be a string");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use reportError on this line too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Maybe not, we just call check in other places)

@tmeasday
Copy link
Contributor

tmeasday commented Jul 4, 2016

@laosb I made some comments. It looks mostly like we had / you added tests that are now failing because the behaviour is stricter than before. We should just fix those tests to expect errors to be thrown (using test.throws) and I think we'll be good.

@laosb
Copy link
Contributor Author

laosb commented Jul 30, 2016

Not sure about what's happening on circle ci. @tmeasday

@abernix
Copy link
Contributor

abernix commented Aug 1, 2016

@laosb I would probably rebase this against devel, to start with; a lot has changed in devel since it was rebased last.

@laosb
Copy link
Contributor Author

laosb commented Aug 2, 2016

@abernix Yeah I think we should do that. Is it possible that the CircleCI results are related to outdate?

@abernix
Copy link
Contributor

abernix commented Aug 2, 2016

That's just the first step to solving CI bugs – especially when it seems that everything is failing in the way it is, you might have been half-way between commits or something when this was originally branched.

@tmeasday
Copy link
Contributor

tmeasday commented Aug 2, 2016

Looks like there's one failing test left @laosb!

@laosb
Copy link
Contributor Author

laosb commented Aug 3, 2016

@tmeasday Yeah, but I don't know how to fix it. The code does throws an error according to the log, but the test suite complains about no error was thrown.

@laosb
Copy link
Contributor Author

laosb commented Aug 3, 2016

Oops, my fault of using pull...

@tmeasday
Copy link
Contributor

@laosb I would try rebasing your commits -- something like

git fetch
git checkout your-branch
git reset --hard <last-commit-hash-of-yours>
git rebase <commit-where-you-branched-off-devel> --onto origin/devel

@laosb
Copy link
Contributor Author

laosb commented Aug 17, 2016

Ok, just rebased!

@laosb
Copy link
Contributor Author

laosb commented Aug 18, 2016

Exception in delivering result of invoking 'changePassword': Error: Incorrect password [403]
    at reportError (http://localhost:4096/packages/accounts-password.js?hash=2509f4ba185764fc21922993e746e175ed4a40c3:143)
    at http://localhost:4096/packages/accounts-password.js?hash=2509f4ba185764fc21922993e746e175ed4a40c3:228
    at http://localhost:4096/packages/meteor.js?hash=ed600264974381dc7fe10e24064e3d8c8a8eaa14:1105
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:3557
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:3577
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:4738
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:3385
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:2736
    at http://localhost:4096/packages/underscore.js?hash=27b3d669b418de8577518760446467e6ff429b1e:152
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:2737
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:175
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:1160
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:1218
    at http://localhost:4096/packages/ddp-client.js?hash=2da97e4abeeb8a6d368dcaee62429eca9ff5faca:1365
C: tinytest - passwords - changing passwords : !!!!!!!!! FAIL !!!!!!!!!!!
{"groupPath":["tinytest","passwords"],"test":"changing passwords","events":[{"sequence":110,"type":"fail","details":{"type":"throws","message":"did not throw an error as expected","asyncBlock":4},"cookie":{"name":"passwords - changing passwords","offset":0,"groupPath":["tinytest","passwords"],"shortName":"changing passwords"}}]}

According to the log, it did threw an error but the test suites didn't seen it. @tmeasday can you take a look whether I did something wrong?

@tmeasday
Copy link
Contributor

@laosb the reasons that test is failing is that the error is thrown in a callback (i.e. after the server returns a result of the method call). There's no way on the client to have this thrown as an error you can try {} catch, which is why it ends up getting logged to the console and the test fails.

I think it's OK in this case to not include a test for that behaviour. I've removed the test and I'm merging the PR!

@tmeasday
Copy link
Contributor

Closing in favour of #7695

@tmeasday tmeasday closed this Aug 23, 2016
@laosb laosb deleted the laosb-rebase-5681 branch August 26, 2016 12:30
tmeasday pushed a commit that referenced this pull request Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants