-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
random false positive "Unhandled rejection Error" after upgrading to 3.5.1 #1468
Comments
I'm having a similar problem. Here is some code to reproduce the potential bug:
It produces the following error:
Without using async/await a similar error is produced:
Error:
Thank you. [edit] By using .catch(err=>{}) instead of .error(err=>{}) the bug seems to go away. Works as expected:
|
no issue - bson-objectid@1.2.1 - compression@1.7.1 - express@4.16.2 - moment-timezone@0.5.14 - mysql@2.15.0 - nconf@0.8.5 - sanitize-html@1.15.0 - simple-html-tokenizer@0.4.3 - superagent@3.8.0 IMPORTANT: - we are unable to bump moment and bluebird at the moment, because in both releases there is a bug which breaks our tests - i didn't investigate a lot, but there is petkaantonov/bluebird#1468 - and for moment, a couple of reports came in for .19 regarding a wrong date behaviour
@danielesegato Can you possibly simplify your example without all the jasmine-specific stuff? It's hard to reason through if you don't know jasmine. I just fixed another similar bug with #1489 and I'm wondering if this issue might be related - maybe I can help, but at present I can't really work out what's going on in your example. |
I've found rather similar behavior and had reported it at chaijs/chai#1134. Will try the new code on your PR. |
those changes did not resolve my particular issue. |
@Celadora The issue you raise is not a bug, it's intended behaviour.
This is unrelated to original issue raised by @danielesegato. |
@erikerikson's issue is also unrelated to @danielesegato's original issue. @erikerikson's issue is explored in #1501. |
@overlookmotel sorry I forgot to answer you, I don't know how to reproduce the problem in a simpler way cause I do not understand exactly what is causing it. I "solved" it by forcing the use of version Sorry I can't be more helpful. |
I can explain what my code does in respect to the Promise. spyOn(actionHandler, 'validateActionConfig').and.returnValue(Promise.reject(new Error('dummy'))); this create a new rejection promise with an error: Inside .catch((err) => {
expect(actionHandler.validateActionConfig).toHaveBeenCalled();
expect(err.message).toBe('dummy');
}); this part of code receive the error I created above and check the function So, i know for sure, that function has been called and that promise has been returned. In other words, I've handled the error and I don't expect to receive any warning like that. |
I should also add this is not an ON/OFF problem, the warning doesn't always show for the same tests, it seems random and could happen in any of those test using a If you think it is useful I can try to show you an example of the code inside that this.createAction = function() {
return actionHandler.validateActionConfig();
} In reality it's all inside a |
Hi @danielesegato. Thanks for replies. Just so you understand, I'm not a maintainer of bluebird, just this has got me interested. I'd like to help, but it's not crucial to my work so I can't spend too much time on it. I don't know Jasmine, and there's a lot of moving parts in this. Being an intermittent fault will also make it even harder to diagnose. I think only way I can help is if you're able to create a standalone repo with all the elements in place (failing test, the code for I understand if you don't have time for that, but in that case I'm afraid this is likely to remain a mystery! |
@danielesegato I came up against this same issue in my Jasmine test I fixed it by using spyOn(actionHandler, 'validateActionConfig').and.callFake(() => Promise.reject(new Error('dummy'))); My thought is that |
This worked for me in an angular test using |
3.5.1 updated the unhandled rejection to use setTimeout to delay checking if there are unhandled rejections. The functionality of setTimeout has been hijacked by the test framework hence the callback runs earlier than expected. |
|
@petkaantonov I don't think this is for us to fix to be honest - this is something the test framework should take care of. |
Ideas for how welcome by the way (I help maintain lolex which is likely the fake timers library) |
I've this weird issue with jasmine testing framework and bluebird: it sometimes (not consistently) produce errors in the console log like this one:
Those are actually printed in the logs but do not make the test fail. In fact the test succeed, a test exhibiting the issue may look something like this:
The
spyOn
is jasmine way of testing mocked dependencies.sut
is the subject under test. This test check our functioncreateAction
forward any rejectiong error from the call toactionHandler.validateActionConfig()
by returning a rejection promise when the function is called.That promise is then catched, as you can see, and we also check the error is exactly the one throw there. So the promise IS catched, but somehow it is detected as uncatched.
Furthermore this is not an on/off problem. Some test randomly exhibit this behavior, some never do.
This didn't happen with bluebird 3.5.0 and, according to your 3.5.1 release note (https://github.com/petkaantonov/bluebird/releases/tag/v3.5.1) you changed something in the Unhandled Promise rejection.
Can you shed some light on what's possibly going on?
Thanks!
related dependencies
and...
I initially posted this as a comment to an old issue here #493 and opened a bug to jasmine here: jasmine/jasmine-npm#124
But after some further testing with different versions of jasmine and bluebird I'm fairly certain this is introduced by a change in bluebird.
The problem DID NOT happen on bluebird version 3.5.0.
And I think this problem is related to #1404
The text was updated successfully, but these errors were encountered: