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: transfer mocked response as ArrayBuffer to the worker #1337

Merged
merged 6 commits into from Jul 18, 2022

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Jul 16, 2022

GitHub

Changes

  • Removes the streaming of mocked responses from the client to the worker. I've come to realize this internal change introduced more problems than issues it solved. We should design proper stream support in Support ReadableStream as a mocked response body #1336, and we may need to wait for all browsers to support sending ReadableStream as a transfer object on postMessage().
  • Refactors the worker message channel to support transport in postMessage().
  • Sends mocked response body as ArrayBuffer to the worker.
  • Removes INTERNAL_ERROR worker event. Internal (request handler) errors are handled in the library now, and the library sends a regular mocked response to the worker in their case.
  • Changes the shape of the object transferred from the client to the worker.

Roadmap

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 16, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 938fa40:

Sandbox Source
MSW React Configuration

@kettanaito kettanaito changed the title feat: transfer mocked response to the worker feat: transfer mocked response as ArrayBuffer to the worker Jul 16, 2022
@kettanaito
Copy link
Member Author

This change can't introduce a regression because ReadableStream as a mocked response body is not yet supported.

@kettanaito kettanaito marked this pull request as ready for review July 18, 2022 12:14
@kettanaito kettanaito requested a review from 95th July 18, 2022 12:35
@kettanaito
Copy link
Member Author

Hi, @95th 👋 Please, would you have a minute to review these changes? Thank you.

@kettanaito kettanaito added the BREAKING CHANGE Pull request introducing breaking changes. label Jul 18, 2022
@kettanaito kettanaito requested a review from 95th July 18, 2022 21:32
@kettanaito kettanaito changed the title feat: transfer mocked response as ArrayBuffer to the worker fix: transfer mocked response as ArrayBuffer to the worker Jul 18, 2022
@kettanaito kettanaito removed the BREAKING CHANGE Pull request introducing breaking changes. label Jul 18, 2022
@kettanaito kettanaito merged commit 95be5f8 into main Jul 18, 2022
@kettanaito kettanaito deleted the feat/worker-transfer-stream branch July 18, 2022 22:40
@kettanaito
Copy link
Member Author

Released: v0.44.2 🎉

This has been released in v0.44.2!

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.

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

Successfully merging this pull request may close these issues.

The response is intermittently not returned in the Firefox. MSW fails to resolve response on Safari
2 participants