-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting TCP Client Receives a Non-Integer #145
Comments
@dalabarge, could you provide a reproducible code? I am having issues reproducing your problem. |
Not able to produce a repeatable trace. I believe it's caused by a Java exception because the internally tracked |
@dalabarge, I think it could be caused by calling |
My pseudo-code flow without all the app specific stuff is as follows. I've annotated with rationale and possible issue within my close() method. That said it appears class Component
{
constructor() {
this.socket = null
this.close.bind(this)
}
connect() {
// do a bit of cleanup to ensure clean state before creation new socket
this.close()
NetInfo.fetch('wifi')
.then((net) => {
// make sure we're using wifi only
if( net.type !== 'wifi' ) return
const socket = TcpSocket.createConnection(options), () => {
// set the active socket reference for use outside connect()
this.socket = socket
// apply a connection idleness timeout
if( Platform.OS === 'android' ) {
this.socket.setTimeout(10000, this.close)
}
})
socket.on('data', (data) => {
// ...
// inside a state manipulation I do call the
// socket.setTimeout() with a different duration
// but there's no direct calls to close() to reset socket
})
socket.on('close', () => {
// need to cleanup, especially if connection dropped without error
this.close()
// ...
})
socket.on('error', (error) => {
// an error should trigger a connection close so no need to cleanup here
// ...
})
})
// anything goes wrong cleanup socket
.catch(this.close)
}
close() {
// noop indempotent guard
if( ! _.isNil(this.socket) ) {
try {
// should be safe because socket should exist
// ideally I should be able to call indempotently
this.socket.destroy()
} catch(error) {
// noop handler because not interested in errors in cleanup
}
// Possibly this line should move above the try/catch to
// ensure a race time duplicate call doesn't also
// attempt to destroy the socket while inprogress already?
this.socket = null
}
}
} |
@dalabarge, you are right, |
## [5.6.1](v5.6.0...v5.6.1) (2022-04-18) ### Bug Fixes * destroy & end work as no-op on closed streams ([b129cf3](b129cf3)), closes [#145](#145)
🎉 This issue has been resolved in version 5.6.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Getting TCP Client Receives a Non-Integer
I'm getting a significant in uptick of ANRs relating to
getTcpClient(cid)
wherecid
is not an integer:Current behavior
It appears that the
cid
passed togetTcpClient()
inTcpSocketModule.java
when callingend()
is not an integer. The JS side internally manages the_id
and therefore at some point the_id
is a non-integer triggering an exception when this package passes the_id
to theend()
ordestroy()
method as acid
. Seems to be occuring since upgrading from4.x
to5.x
Expected behavior
Only way for that to happen is for the JS to lose a reference or reset the internal
_id
reference and pass it over the bridge. The bridge should protect against such errant calls as a noop to avoid the crash.Relevant information
The text was updated successfully, but these errors were encountered: