Skip to content

Commit e3a4c97

Browse files
committed
corrected stream showing of characters
1 parent a095510 commit e3a4c97

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,10 @@ private void pollIterator(fulamobile.StreamIterator iterator, Promise promise) {
19621962
, 50); // Reduced delay for better responsiveness
19631963
}
19641964
} catch (Exception e) {
1965-
if (e.getMessage().contains("timeout")) {
1965+
if (e.getMessage() != null && e.getMessage().contains("EOF")) {
1966+
emitEvent("onStreamingCompleted", null);
1967+
promise.resolve(null);
1968+
} else if (e.getMessage() != null && e.getMessage().contains("timeout")) {
19661969
// Retry on timeout
19671970
new Handler(Looper.getMainLooper()).post(() ->
19681971
pollIterator(iterator, promise)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@functionland/react-native-fula",
3-
"version": "1.55.0",
3+
"version": "1.55.1",
44
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
55
"type": "module",
66
"main": "lib/commonjs/index",

src/protocols/fx-ai.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ import { DeviceEventEmitter } from 'react-native';
8080

8181
const errorHandler = (error: string) => {
8282
if (active) {
83-
cleanup();
84-
reject(new Error(error || 'Stream error occurred'));
83+
cleanup();
84+
if (error.includes('EOF')) {
85+
// Treat EOF as successful completion
86+
console.log('Stream completed with EOF');
87+
resolve(fullResponse);
88+
} else {
89+
console.error('Stream error:', error);
90+
reject(new Error(error || 'Unknown stream error'));
91+
}
8592
}
8693
};
8794

@@ -90,11 +97,15 @@ import { DeviceEventEmitter } from 'react-native';
9097
DeviceEventEmitter.addListener('onStreamError', errorHandler);
9198

9299
Fula.streamChunks(streamID)
93-
.catch(error => {
94-
if (active) {
100+
.catch(error => {
101+
if (active) {
95102
cleanup();
96-
reject(error);
97-
}
98-
});
103+
if (error.message.includes('EOF')) {
104+
resolve(fullResponse);
105+
} else {
106+
reject(error);
107+
}
108+
}
109+
});
99110
});
100111
};

0 commit comments

Comments
 (0)