ReadableStream passed to an island component argument becomes an empty object
I am passing
ReadableStream to an island component argument becomes an empty objectrender instead of .render somewhere else in your code. Also, make sure that the object is indeed an instance of a or has a method available.undefined at the time you're trying to access it. This could be due to the not being in the expected state or the property not being available on the object.}. Here's the corrected prop definition:Promise in a way that should be correct, as you are using to handle the resolved value.Promise at the time when you're trying to call on it. This could happen if is not being passed correctly to the component or if it's not initialized as a Promise.Promise that resolves to an object with , , , and properties.pending, , or ). In contrast, browsers may log a promise as an empty object or with very little information, which can be confusing but is normal behavior.undefined. This means that the prop may not be passed correctly to the component, or there is an issue with how the promise is being created or resolved.undefined at the time you're trying to call on it in the browser. This could happen if the prop is not being passed correctly to the component or if there's an issue with the promise itself.undefined.GatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayGatewayreaderreaderreaderreaderreaderreaderreaderreaderreaderreaderreaderreaderreaderrender.read is not a functionreader.read()reader.read().catch()ReadableStreamDefaultReaderreadConnect.tsxConnect.tsxConnect.tsxreadablereadablereadablereadableGateway.tsxGateway.tsxconsole.log(reader)reader.read is not a functionread()read()read()wsswsswsswssUncaught TypeError: Cannot read properties of undefined (reading 'then')Uncaught TypeError: Cannot read properties of undefined (reading 'then')Uncaught TypeError: Cannot read properties of undefined (reading 'then')Uncaught TypeError: Cannot read properties of undefined (reading 'then')Uncaught TypeError: Cannot read properties of undefined (reading 'then')Uncaught TypeError: Cannot read properties of undefined (reading 'then')Uncaught TypeError: Cannot read properties of undefined (reading 'then')wss.openedwss.openedWebSocketStreamWebSocketStreamWebSocketStreamWebSocketStreamWebSocketStreamWebSocketStreamopenedopened.then().then().then().then().then().then()console.log(wss)console.log(wss)>connconnconnconnconnconnconnconnconnconnconnconnconnconnconnconnconnconnconnconnconsole.log(conn)console.log(conn)console.log(conn)console.log(conn)writablewritableextensionsextensionsprotocolprotocolPromise {}Promise { <state> }<state>fulfilledrejectedconsole.log('message recived')console.log('message received')console.log('message received')<Gateway readable={readable} message={message} />export const Gateway: FunctionComponent<{
reader: ReturnType<Awaited<WebSocketStream['opened']>['readable']['getReader']>
message: Signal<string>
}> = ({ reader, message }) => {
// ...
}<Gateway reader={readable.getReader()} message={message} />export const Gateway: FunctionComponent<{
readable: ReadableStream
message: Signal<string>
}> = ({ readable, message }) => {
const reader = readable.getReader();
// ...
}export const Gateway: FunctionComponent<{
wss: WebSocketStream;
message: Signal<string>;
}> = ({ wss, message }) => {
// ...
}export const Gateway: FunctionComponent<{
wss: WebSocketStream;
message: Signal<string>;
}> = ({ wss, message }) => {
// ...
}// islands/Gateway.tsx
/// <reference lib='deno.unstable' />
import type { FunctionComponent } from 'preact'
import type { Signal } from '@preact/signals'
export const Gateway: FunctionComponent<{
conn: Promise<{
readable: ReadableStream<string | Uint8Array>
writable: WritableStream<string | Uint8Array>
extensions: string
protocol: string
}>
message: Signal<string>
}> = ({ conn, message }) => {
console.log(conn) // gets logged in vs code console as expected but gets logged as an empty object in the browser console
conn.then(({ readable }) => { // error, only shown in browser console, Uncaught TypeError: Cannot read properties of undefined (reading 'then')
readable.getReader().read().then((msg) => {
message.value = msg.value as string
console.log('message recieved')
})
})
return (
<div class='max-w-screen-md mx-auto flex flex-col items-center justify-center'>
<div class='flex gap-8 py-6'>
<button>{message}</button>
</div>
</div>
)
}