itinance / itinance/react-native-fs

Bug Report: RNFS.downloadFile crashes with null pointer when server sends TCP RST (connection reset)

Open
#1,258 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

## Bug Report: RNFS.downloadFile crashes with null pointer when server sends TCP RST (connection reset)

### Problem Description
When `RNFS.downloadFile()` attempts to download from a server that sends a TCP RST (reset packet), the app crashes with a null pointer exception in native code instead of properly rejecting the promise with a network error.

### Environment
- **react-native-fs:** 2.20.0
- **React Native:** 0.82.1
- ## Bug Report: RNFS.downloadFile crashes with null pointer when server sends TCP RST (connection reset)

### Problem Description
When `RNFS.downloadFile()` attempts to download from a server that sends a TCP RST (reset packet), the app crashes with a null pointer exception in native code instead of properly rejecting the promise with a network error.

### Environment
- **react-native-fs:** 2.20.0
- **React Native:** 0.72.0
- **Platform:** Android
- **Device:** Multiple Android devices

### Steps to Reproduce
1. Set up a server that rejects connections with TCP RST (e.g., port closed, firewall blocking)
2. Attempt to download using `RNFS.downloadFile()`
3. Observe app crash instead of graceful error handling

### Code to Reproduce
```javascript
import RNFS from 'react-native-fs';

async function testDownload() {
try {
// Server that will send TCP RST (e.g., port 81 on a server that only has port 80 open)
const result = await RNFS.downloadFile({
fromUrl: 'https://example.com:81/nonexistent.apk',
toFile: `${RNFS.DocumentDirectoryPath}/test.apk`,
readTimeout: 30000,
connectionTimeout: 30000,
}).promise;

console.log('Success:', result); // Never reached
} catch (error) {
console.log('Error caught:', error); // Never reached - app crashes
}
}

### Steps to Reproduce
1. Set up a server that rejects connections with TCP RST (e.g., port closed, firewall blocking)
2. Attempt to download using `RNFS.downloadFile()`
3. Observe app crash instead of graceful error handling

### Code to Reproduce
```javascript
import RNFS from 'react-native-fs';

async function testDownload() {
try {
// Server that will send TCP RST (e.g., port 81 on a server that only has port 80 open)
const result = await RNFS.downloadFile({
fromUrl: 'https://example.com:81/nonexistent.apk',
toFile: `${RNFS.DocumentDirectoryPath}/test.apk`,
readTimeout: 30000,
connectionTimeout: 30000,
}).promise;

console.log('Success:', result); // Never reached
} catch (error) {
console.log('Error caught:', error); // Never reached - app crashes
}
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.