fix(mobile): attaching larger images no longer crashes with a BigInt error#34087

merged1
main
t3/fix-image-upload-bigint-error
opened1d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 18h ago

Attaching images on mobile sometimes crashed with TypeError: Cannot convert BigInt to number (in onProgress → onUploadProgress). It happened only when the native upload sent a progress event, which takes a larger image or a slow connection. Small, fast uploads only get expo's final JS-side event, which uses real numbers.

expo-file-system sends bytesSent/totalBytes as Swift Int64, and in SDK 58 expo-modules-jsi always turns Int64 into a JS bigint, even though expo's types say number. bytesSent / totalBytes then gave 0n, and Math.min(1, progress) in the upload queue threw.

The fix converts both counts with Number() before dividing. That also puts the progress bar right: BigInt division dropped the fraction, so the bar stayed at 0 until the upload finished. The existing upload test now reports BigInt progress from the mocked file.upload. Before the fix it fails with expected [ 0n ] to deeply equal [ 0.25 ].

Done by Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

Checks

1 failing · 23 successful · 16 skipped
Some checks failed

Failing1

8963f4c

Added 1 commit

  • fix(mobile): attaching larger images no longer crashes with a BigInt error8963f4c

Thanks for this. Main already has the change, as of 3cb99ced5b79f74628065952098cc1cf2d829f0e.

The same change is already on main in 3cb99ced5b: both native byte counts are converted to numbers before calculating upload progress.

Your regression assertion is included too, so the complete fix has landed and needs no further review here.

Closing as superseded.