Ask questionsInsight required: Resource (TCP) errors
Please ignore - I hadn't accounted for the fact that multiple errors may be emitted.
Currently, when a Deno TCP socket has an error, I attempt to call
If it was a read error, everything works as expected (resource exists) If it was a write error, I get an error that there is no such resource (resource doesn't exist)
I'm wondering is this universal - will different types of read errors cause the resource to be removed, or will some types of write errors not remove the resource?
Why does this happen? is it to do with half open sockets? is it a bug?
At present, I am checking the value of
Deno.resources()[rid]before closing. Hopefully that will get me by for now.
Answer questions realJoshByrnes
I wrote this test (overkill) and discovered that it's not actually the issue I expected. The error was because Deno can emit multiple errors, and I am closing on error - duh!
Ironically, in every test I've done the read error happens first, followed by the write (the second
.close() was causing the error - correctly)
Sorry about that.