Enforce Order of Recordings
See original GitHub issueContext
We use nockBack
and would like to enforce the order of our recording files. Ideally there is a timeout option that can be set to allow for parallel recordings.
Example: One request is made, then two other requests are made in parallel. Assuming a correct recording file already exists, the first request should match the first recorded request. However the second request might match the second or third recording. Ideally, if the request does not match the next recording, the request (nock) should wait for that recording to be consumed by any parallel requests.
Alternatives
Currently there doesn’t seem to be any way to enforce this satisfactorily, let alone the parallel consideration mentioned above.
Has the feature been requested before?
Didn’t find an anything surprisingly?
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:
- Created 5 years ago
- Reactions:6
- Comments:48 (21 by maintainers)
@simlu I’m curious if you’ve looked into implementing a test for your use case using the
request
orreplied
events emitted on Scopes. https://github.com/nock/nock#events@paulmelnikow I think it is necessary to delay since otherwise you can not handle parallel requests. And those are very essential for performance for us. Immediate nock failure would just result in random failures for those tests…
Unless… the nock interception prevents any true async handling and hence the order would always be consistent? In that case it might be fine? But even then the recording order might not be the same as the later execution order (or does nock record in order of request start, not end?).
I realize that I don’t know enough about the internals of this library to answer that question 😃