niieani / puppeteer-intercept-and-modify-requests

The best way to intercept and modify requests done by a Chromium website when instrumented by puppeteer
Apache License 2.0
48 stars 8 forks source link

Response stage is recognized as request stage #29

Closed jacksky007 closed 9 months ago

jacksky007 commented 9 months ago

Hi. Thanks for your tool which is helping me a lot these days. I'm facing an edge case when I get the response from the server the response code is absent. The code below treats it at request stage, but in fact it is at response stage.

      if (!responseStatusCode) {
        // handling a request

https://github.com/niieani/puppeteer-intercept-and-modify-requests/blob/main/src/main.ts#L136

Can we do some minors change to the code,

  1. change the condition to if (modifyRequest && !responseStatusCode)
  2. give the response code a fallback value to 200 change this responseCode: responseStatusCode, to `responseCode: responseStatusCode || 200,

    https://github.com/niieani/puppeteer-intercept-and-modify-requests/blob/main/src/main.ts#L202

Thanks again if you can update as above or if you have better solution for such edge case.

niieani commented 9 months ago

Hi @jacksky007! Thanks for your report. I'm glad the tool is helpful! I will release a fix soon.

github-actions[bot] commented 9 months ago

:tada: This issue has been resolved in version 1.3.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: