question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detect unmatched body and match anyways

See original GitHub issue

Context

We use nockBack and would like to improve cassette self-healing when the request signatures changes slightly. Ideally there would be a hook that allows us to:

  1. Detect that no body is matched and
  2. Force match the next recording in the cassette and replay that response (so further code can execute correctly).

We already have extensive self-healing capabilities of cassettes implemented, so this would allow us to extend / improve on that. The limitation of the self healing as implemented is that after the first recording is healed, the response is not replayed.

Alternatives

Currently we have to manually go through the cassettes and adjust the body to match the changes if there are requests depending on failed requests. This is feasible for small cassettes and we have been doing it for years now. However when a cassette contains thousands of requests this is no longer feasible and we need to re-record (which can be very hard when it requires complex state setup).

Has the feature been requested before?

AfaIk this feature has not been requested before.

If the feature request is accepted, would you be willing to submit a PR?

Sure. As usually the biggest problem in this code base is figuring out where to make the change, so I’ll need help with that 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
simlucommented, Feb 5, 2020

We’ve successfully implemented our change here using filteringRequestBody. We just assume that the request ordering in the recording is correct and hence do not need to know if “any interceptor matches the current request” (since we can just assume it’s the next available one).

Closing this since it seems to work fine.

@paulmelnikow Just a quick note on your comment that our “use case is kind of unusual”: We are using nockBack (which not a lot of people seem to use) and our requirements seem to be just a very natural evolution from using nockBack a lot. I would think that our use case would already be supported if more people were using nockBack.

I’m really not sure why nockBack isn’t more popular, since it makes all the manual setup in code unnecessary and the code becomes objectively much cleaner.

0reactions
simlucommented, Feb 6, 2020

@paulmelnikow I’m giving a talk on test methodologies next week with focus on “testing the hard parts”. Recording and replaying external requests is going to be part of that. I’ll be writing some simple test cases using node-tdd and might post them here. It should make the value of node-tdd a lot clearer and hopefully help deciding on actionables for nockBack.

As you mentioned, I think a big part of why nockBack isn’t used more is documentation. The goal should be to have a clear and concise way to use nockBack and document that. Our wrapper node-tdd is fool-proof and allows “switching record-replay on” without requiring any additional knowledge beyond knowing what cassettes are and that they are automatically re-recorded when deleted.

I think more people would use nock if it was simpler to set up and not require any understanding of what requests are, how they are intercepted etc. So pushing nockBack forward would imo greatly help the popularity of nock if done correctly.

Does that all make sense to you? I really haven’t used nock much beyond what nockBack does. So am curious if you have a different take on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can you find someone you matched with on Tinder if ... - Quora
If you've matched with them, and neither of you have unmatched each other, then yes. You can pull up your matches from the...
Read more >
how to fix Unmatched end tag error in IE 10 - Stack Overflow
In answer html <div id="container"> is missing. In site this is present and all tags match. Message was caused by nesting div inside...
Read more >
16 Reasons She Unmatched You On Tinder - TextGod.com
Another way to get unmatched is to ask too many questions. Even if they're good, they will eventually annoy your Tinder match. Why?...
Read more >
VLOOKUP(), MATCH() and INDEX() - Chandoo.org
In this case, we can use MATCH() to find out which row has net sales 1,799 and INDEX() to return the name of...
Read more >
Importance Of Matching Verbal And Nonverbal Cues
What happens when the words you speak and your body language don't match? Audiences will ultimately believe body language every time.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found