Kitodi
Kitodi
Explore posts from servers
CDCloudflare Developers
Created by Kitodi on 1/30/2024 in #workers-help
TCP Sockets read() function got stuck
Created GitHub issue in case if this is a bug or it is intended and needed more action to prevent this happening. https://github.com/cloudflare/workers-sdk/issues/4882
3 replies
CDCloudflare Developers
Created by Kitodi on 1/30/2024 in #workers-help
TCP Sockets read() function got stuck
Similar use case when I do write and expected to receive a response, you do the write() first then read() but when try to call again the read() it will get stuck.
import { connect } from 'cloudflare:sockets'

const socket = connect(...);

socket.writable.getWriter().write(...);
socket.readable.getReader().read(); // Valid: Expected a response from the server
// Tries to read again to reproduce the behaviour
socket.readable.getReader().read(); // Invalid: The program got stuck here and there are no returns or error throwns
import { connect } from 'cloudflare:sockets'

const socket = connect(...);

socket.writable.getWriter().write(...);
socket.readable.getReader().read(); // Valid: Expected a response from the server
// Tries to read again to reproduce the behaviour
socket.readable.getReader().read(); // Invalid: The program got stuck here and there are no returns or error throwns
3 replies