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

fix(setupWorker): emit the correct life-cycle events for bypassed requests #2094

Merged
merged 4 commits into from Mar 17, 2024

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Mar 16, 2024

@kettanaito
Copy link
Member Author

Added a failing test for the bypass scenario. Also added a missing test for the passthrough scenario (that one is passing).

@@ -206,13 +206,6 @@ async function getResponse(event, client, requestId) {
return passthrough()
}

// Bypass requests with the explicit bypass header.
// Such requests can be issued by "ctx.fetch()".
const mswIntention = request.headers.get('x-msw-intention')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both bypassed and passthrough requests must emit the REQUEST event to the client so the client (worker context) stores that request in memory. Then, it can find the request instance based on the requestId when receiving the RESPONSE event, which right now both mocked and bypassed responses do send correctly.

@kettanaito kettanaito merged commit c485989 into main Mar 17, 2024
12 checks passed
@kettanaito kettanaito deleted the fix/worker-request-bypass branch March 17, 2024 11:51
@kettanaito
Copy link
Member Author

Released: v2.2.6 🎉

This has been released in v2.2.6!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

@dalhaan
Copy link

dalhaan commented Mar 18, 2024

Hey @kettanaito,

Did you mean to leave the following line:
console.log('RESPONSE LISTENER', responseJson, context.requests)

in src/browser/setupWorker/start/createResponseListener.ts?

After upgrading, the logs seem to be spamming the console and I can't seem to be able to disable them.

@piotr-cz
Copy link
Contributor

There is an issue #2098 for added console.log line

@kettanaito
Copy link
Member Author

@piotr-cz, thanks! Fixed in #2099.

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