-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Serialization bug when uploading files in browser mode #9165
Copy link
Copy link
Labels
Description
Describe the bug
When uploading a file in browser mode using the Interactivity API, the file size and contents do not match what's being uploaded.
Specifically, when uploading a file using this test code:
// 1. Create a file with exactly 4 bytes of content
const fileContent = 'test';
const file = new File([fileContent], 'test.pdf', { type: 'application/pdf' });
// 2. Perform the upload using the Vitest Browser Mode Interactivity API
const input = screen.getByTestId('file-input');
await input.upload(file);The uploaded file as seen from the component's point of view is a 23-bytes long binary string.
I have written a minimal reproduction.
Some additional information:
- the bug occurs on my local machine (2023 MacBook Pro) but not on StackBlitz. It might be specific to macOS / Apple Silicon.
- the bug is not browser specific: I have reproduced it with Chromium, Firefox and Safari.
- the incorrect length and contents change with the MIME type
- using an actual file instead of an in-memory
Fileinstance does not trigger the bug - using
DataTransferanddispatchEventdoes not trigger the bug
Reproduction
System Info
System:
OS: macOS 26.1
CPU: (12) arm64 Apple M3 Pro
Memory: 1.06 GB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - /Users/olivier/.nodenv/versions/22.18.0/bin/node
Yarn: 4.11.0 - /Users/olivier/.nodenv/versions/22.18.0/bin/yarn
npm: 11.6.2 - /Users/olivier/.nodenv/versions/22.18.0/bin/npm
pnpm: 10.20.0 - /Users/olivier/.nodenv/versions/22.18.0/bin/pnpm
Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 143.0.7499.40
Firefox: 145.0.2
Safari: 26.1
npmPackages:
@vitejs/plugin-react: ^5.1.1 => 5.1.1
@vitest/browser: ^3.2.4 => 3.2.4
@vitest/ui: ^3.2.4 => 3.2.4
playwright: ^1.57.0 => 1.57.0
vite: ^7.2.4 => 7.2.6
vitest: ^3.2.4 => 3.2.4
vitest-browser-react: ^1.0.1 => 1.0.1Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable