Open cshfang opened 6 months ago
Referencing other issues:
I'm seeing this as well in an Expo Development build.
@byCedric Good morning, any update on this? For slow internet connection, it is 10x user experience to be able to show progress updates on upload. With this not functioning, the "upload bar" in my app just sticks until it is complete. Getting the onProgress
callbacks solves this issue.
Did you find a work around for this @cshfang ?
@ChristopherGabba - as far as i know this only impacts expo go, as reported here, so it should not have any impact on your users. are you experiencing something different?
Thank you for filing this issue! This comment acknowledges we believe this may be a bug and there’s enough information to investigate it. However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.
this seems to coincide with the release of network debugging: https://blog.expo.dev/expo-sdk-49-c6d398cdf740
i was able to reproduce it in expo go in a new app by copying @cshfang's app code over to a new project. outside of expo go, it works as expected (eg: via npx expo run:ios
)
import React from 'react';
import {Button, StyleSheet, View} from 'react-native';
const url = 'http://127.0.0.1:3000';
export default function App() {
const upload = () => {
const xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.upload.addEventListener('progress', event => {
console.log('Event: Upload progress', event);
});
xhr.upload.onprogress = event => {
console.log('Upload progress', event);
};
xhr.onprogress = event => {
console.log('Progress', event);
};
xhr.onload = event => {
console.log('Completed', event);
};
xhr.send('just a string');
};
return (
<View style={styles.container}>
<Button title="Upload" onPress={upload} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
// LOG Event: Upload progress {"isTrusted": false, "lengthComputable": true, "loaded": 13, "total": 13}
// LOG Upload progress {"isTrusted": false, "lengthComputable": true, "loaded": 13, "total": 13}
// LOG Progress {"isTrusted": false, "lengthComputable": false, "loaded": 13, "total": -1}
// LOG Completed {"isTrusted": false}
and then running his provided server code:
const http = require('http')
const server = http.createServer(function(request, response) {
if (request.method == 'POST') {
var body = ''
request.on('data', function(data) {
body += data
})
request.on('end', function() {
console.log('Body: ' + body)
response.writeHead(200, {'Content-Type': 'text/html'})
response.end('post received')
})
}
})
const port = 3000
const host = '127.0.0.1'
server.listen(port, host)
console.log(`Listening at http://${host}:${port}`)
@brentvatne @Kudo I am experiencing this issue in my production app on Expo 51 as well (on iOS)so it's not just Expo Go. I'm unable to get progress feedback on uploads.
@ChristopherGabba - we can only help on reports where there is a minimal reproducible example. we are unable to reproduce this outside of expo go. please share a minimal reproducible example in a new issue if you believe that you have found a bug - this issue is about expo go
@brentvatne I apologize, I'll work on it. @cshfang posted this issue on behalf of the AWS team who were troubleshooting my issue on AWS: https://github.com/aws-amplify/amplify-js/issues/13221 . Essentially using the AWS uploadData
function, all onProgress
callbacks produce no feedback. They dug into the underlying XMLHttpRequest and reported this issue. But the same issue exists on an expo development build and an expo production build for iOS.
@ChristopherGabba - if you can reproduce it without using amplify that would be great! the code provided by the OP in this thread works as expected in a release build
@brentvatne Super strange. The upload progress is actually working on a production TestFlight build, but not on the Expo Dev Build -- just using the basic amplify uploadData
(https://docs.amplify.aws/react-native/build-a-backend/storage/upload-files/) function. I coded it into the app, and it wasn't working on Dev and as soon as I downloaded the Testflight build it works awesome -- still can't get any in the development build though.
Regardless, I have not been able to reproduce it without the basic Amplify library, but just providing an update.
Minimal reproducible example
https://github.com/cshfang/xhr-issue
What platform(s) does this occur on?
iOS
Did you reproduce this issue in a development build?
No (tested in Expo Go)
Summary
XMLHttpRequestUpload events appear to be not firing in Expo Go 49+
Related discussion found here: https://github.com/expo/expo/discussions/27448
Example code of xhr events not firing:
Environment
Run within
xhr-latest
(app presenting with issue) directoryExpo Doctor Diagnostics
Run within
xhr-latest
(app presenting with issue) directory