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

Upload Progress event for XHR not firing in browser #128

Open
cjpbright opened this issue Nov 15, 2024 · 2 comments
Open

Upload Progress event for XHR not firing in browser #128

cjpbright opened this issue Nov 15, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@cjpbright
Copy link

I'm trying to simulate a file upload with progress feedback using MSW (to write frontend for an upcoming API), but am struggling to get the progress event to fire when using MSW.

I've tried a few different approaches and the MSW interception fires correctly, and I can read the sent file content correctly inside the handler and return a response, but nothing seems to trigger the progress event that I would expect.

Reading previous threads on this subject for MSW suggest that support should exist in 2.0+, so this may be a lack of understanding on my part, but I would appreciate some help as to whether this is a bug, an unsupported case or an issue with the implementation.

I have created an isolated reproduction using a vite site base and the axios library here; I have also tried pure XHR with similar lack of success.

Thanks

@kettanaito
Copy link
Member

@cjpbright, thanks for raising this. In the browser, MSW fully relies on the Service Worker API. If it dispatches the progress event on XHR or not is, unfortunately, not up to us.

One thing that comes to mind, try sending request body as a ReadableStream. I may look into the reproduction repo once I have a moment.

@kettanaito kettanaito added the help wanted Extra attention is needed label Nov 16, 2024
@cjpbright
Copy link
Author

Thanks for the reply - I'll try the approach you suggested and do a bit more digging, see if I can get any further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants