-
Notifications
You must be signed in to change notification settings - Fork 79
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
Mock Server Startup API fails #314
Comments
This is an absolutely awesome report! Super detailed, logs included, tested in OSX and Windows and a reproducible example!? You're amazing! I think this might be related to the very last version where needle was introduced. My guess is that |
Definite virtual hi fives @fernanfs ! |
Which was the last Version of pact-node which did not include needle? I'll downgrade to that version and see if that changes anything. If so, we would have a workaround in the meantime. |
Sorry, I wasn't very clear:
This should have said "related to the latest release, in which needle was introduced". So, any version before 11.1.0. Specifically, try 11.0.1 of pact-core, or 10.12.2 of pact-node. I may have a fix for you - I'm about to release 11.1.1 of pact-core now, and if that works, I'll back-port it to pact-node. A related aside: We have a number of challenges bringing karma-pact forward to the next version of pact-js (which will use the rust core, bringing substantial speed improvements, and also the long-overdue support for pact spec v3, which has a number of improvements around provider states, matchers etc). We're considering sunsetting both karma-pact and pact-web - I'd like to write up my thoughts on this in more detail, but to summarise quickly: My personal view is that running API client tests through the browser encourages including UI in your pact tests, and I don't think that's something we should encourage. I see the argument for "well, this is the environment we're deploying too, so we should be testing in it", but as I understand it, modern transpilation practices largely make that argument moot (I may be wrong here - I haven't done a lot of digging on the topic). Additionally, both pact-web and karma-pact are challenging to maintain, so it's a lot of work to keep the ability to run tests in an environment that (personally) I don't really believe it. However, on the other hand, I don't want pact to have opinions on how you write your tests. Just because it's not my personal preferred style, doesn't mean that we shouldn't support it. My personal style is not "correct" or "best practice" (even if I might enjoy claiming it is if we were arguing about testing over a beer). Also, I like the idea that pact supports doing something a little unusual - I don't know if many tools implement the ability to test actual http request/responses from karma. So it's a cool differentiator. Anyway, if you're using karma-pact extensively and have thoughts on this, we'd love your thoughts on this issue: pact-foundation/pact-js#626 |
Also github interpreted "may fix #XX" as "did fix #XX". Reopening, hopefully only for a short time. |
Update: 11.1.1 does not fix this issue. Hmm. |
I'm really amazed about your extremely fast feedback. Thank you! I tested v11.1.1, unfortunately with no success:
I then went on to give v11.0.1 of pact-core a shot. There is a difference in the execution, but unfortunately doesn't bring me much further. I don't see the exception, but the application hangs once the mock server is started.
But the mock server is actually running, which I can verify with
regarding your side note: I get your point on using karma for pact contract tests. I tend to disagree with you on that but am happy to discuss in pact-foundation/pact-js#626 |
I've just been bashing my head against this crash for the past hour. Debugging it seems to lead to a function that never returns :/ I started to suspect the M1 mac isn't playing nicely with deasync, so I'm switching to an intel one to eliminate that.
You're so welcome! It's a combination of I happened to be having an open source day, and this issue was so well written and complete that I wanted to prioritise it.
Awesome! Yes please! |
So, I think it's hanging because of a bug in deasync: abbr/deasync#140 I'm not sure if the uncaught exception is happening because of that, too, but if I wrap the whole |
Ok, after some further digging, I found this gem in the original project that deasync was forked from:
😂 The issue of deasync not working in node 12 / 14 has a minimal repro already in the issue I linked, but no activity yet on a fix. In the meantime, I think your use case is for karma-pact, which only used deasync because Karma didn't support async plugins. It looks like Karma supports async plugins since 4.3.0, so maybe we can rework karma-pact to work around this. |
Thanks a lot for the time you've put into this. My use case is indeed primarily using karma-pact and porting it to the async plugins api seems very sensible to do so. I'll dig into that, if you didn't do so already. Maybe I can thank you by creating at least a PR for that. ;-) |
Yes please! I definitely don't have the capacity to look at anything karma-pact related until after the next major pact-js release. It probably needs a number of other quality of life updates, too - I would guess it has at least some outdated dependencies. |
If you start looking at it and have any questions (or just want a general overview of anything), you're very welcome to pm me on slack (or ask in #pact-js-development). If you're not already in the pact-foundation slack, you should be able to generate yourself an invite here: https://slack.pact.io/ |
Closing this, because thanks to @fernanfs (pact-foundation/karma-pact#27) karma-pact v3.0.0 no longer uses deasync, and it looks like this is a deasync issue rather than a pact issue. |
…service during polling (may fix #314)
Software versions
This has been tested on Windows as well as on macOS
General Library Versions
Windows
macOS
Issue Checklist
Please confirm the following:
Description
During the evaluation of karma-pact (keep reading, it is not a karma or karma-pact issue), we stumbled across a problem: the mock server didn't become available and karma did shutdown immediately.
The reason was an exception, that we tried to reproduce in an isolated way. To do this, we've extracted the core logic and executed it without karma (or anything other besides pact).
The following code has been used:
The application crashes and the mock server never becomes available. The reason seems to be an unhandled error somewhere in the codebase:
(full log further down).
This unhandled exception becomes handled through deasync and thus terminates the process. I suspect that the exception is being caused by
__waitForServiceUp()
or__call()
inservice.ts
, but was unable to track the exception down.The code has been tested with
@pact-foundation/[email protected]
and@pact-foundation/[email protected]
Expected behaviour
index.js
should be executed without any problems. A request to the mock server should be possible at the end.Steps to reproduce
The project demonstrating the issue can be found here:
https://github.com/fernanfs/pact-playground
Running the example is simple:
npm install
node index.js
Relevant log files
This is the output generated on Windows when running
index.js
:The text was updated successfully, but these errors were encountered: