Git Product home page Git Product logo

Comments (7)

kettanaito avatar kettanaito commented on June 17, 2024

This needs to be verified in an actual usage scenario.

from interceptors.

sean-hernon avatar sean-hernon commented on June 17, 2024

Does this affect only the headers? I am planning to use the library to intercept and log outgoing http requests. I have a single middleware function that logs the method and url.href and does not return a mocked response. Does this sound like a scenario that will encounter the issue, with a high enough volume of requests and possible matching urls?

Thank you for your advice.

from interceptors.

kettanaito avatar kettanaito commented on June 17, 2024

Hi, @sean-hernon. I believe the issue is related to subsequent requests to the same endpoint, not necessarily to headers. I haven't got a capacity to reproduce this, would you mind giving me a hand? If we can get a reliable reproduction repository where this issue occurs, we can track it down and find a solution.

from interceptors.

sean-hernon avatar sean-hernon commented on June 17, 2024

Hi @kettanaito yes I would certainly like to help when I get some free time.

In the case where no mocked response is returned, do you foresee that the issue will cause the real request to be corrupted? If two requests made to the same endpoint, but with different methods are issued, do you foresee any conflict there?

from interceptors.

sean-hernon avatar sean-hernon commented on June 17, 2024

I have tried to reproduce this issue, but have had no luck so far. Do you have any more information related to how you encountered the issue?

Edit: To be more specific, I have been able to reproduced the issue like this, using the usual helpers inside the tests -

test('two concurrent requests are processed independently', async () => {
  const requests = await Promise.all([
    prepare(
      httpRequest('http://httpbin.org/get'),
      pool
    ),
    prepare(
      httpRequest('http://httpbin.org/get', {
        headers: {
          foo: 'bar',
        },
      }),
      pool
    )
  ])

  expect(requests[1]?.headers).toHaveProperty('foo', 'bar')
})

But this is because prepare uses findRequest, which does not consider headers when looking-up the request in the pool. I wanted to check that the issue was not encountered in this manner.

from interceptors.

kettanaito avatar kettanaito commented on June 17, 2024

Thank you for assistance on this, @sean-hernon! Those insights are most useful.

Please, if you happen to reproduce it, could you submit a pull request with a failing test that does so? It doesn't have to contain a solution straight away, as a reliable reproduction would help us find one much faster. Thanks.

from interceptors.

sean-hernon avatar sean-hernon commented on June 17, 2024

@kettanaito Do you remember what you did exactly to see the issue? Was it exactly as in the steps to reproduce?

from interceptors.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.