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

[Regression 13.0.2] Persistent interceptors using request #2054

Closed
Treyone opened this issue Jul 22, 2020 · 4 comments · Fixed by #2056
Closed

[Regression 13.0.2] Persistent interceptors using request #2054

Treyone opened this issue Jul 22, 2020 · 4 comments · Fixed by #2056

Comments

@Treyone
Copy link

Treyone commented Jul 22, 2020

Behavior
We are using persistent interceptors with scope.persist(). These interceptors have a reply function thats uses the req attribute to read request headers. Our test cases run multiple requests in parallel (using Promise.all in the client code), with different header values.

Up to version 13.0.1, this cas working fine:

  • request 1 -> header value A
  • request 2 -> header value B
  • request 3 -> header value C

Since version 13.0.2

  • request 1 -> header value C
  • request 2 -> header value C
  • request 3 -> header value C

This seems to be due to the fact that since 3b24821, the interceptor.req is now set in intercepted_request_router.js, not in playback_interceptor.js anymore. as other requests arrived in the meantime, the req attribute is overwritten and all reply functions get the last value.
The req arg of playbackFunction still has the good values right before calling the reply function though, here:

if (interceptor.fullReplyFunction) {

Possible solution

As the designed commit is itself fixing a bug, I'm not confident implementing a fix. I could see 2 options:

  • don't set the req attribute in the router but bring it back to the interceptor playback
  • pass the req in a separate argument, not as an interceptor attribute

How to reproduce the issue

See above.

Does the bug have a test case?

No. It could be a new test in test_intercept_parallel.js, where the reply is a function that uses req.headers.

@mastermatt
Copy link
Member

Thanks, I'm taking a look and writing a failing test now.

@Treyone
Copy link
Author

Treyone commented Jul 24, 2020

Great, thanks for having a look so quickly !

@ndelvalle
Copy link

I'm also seeing this behavior in version 13.0.1

@github-actions
Copy link

🎉 This issue has been resolved in version 13.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants