ReadableStream passed to an island component argument becomes an empty object
I am passing
ReadableStream to an island component argument becomes an empty objectGateway component's props. The prop is named reader, but the error message you're seeing in the browser console is render.read is not a function. This suggests that somewhere in your code, you might be mistakenly referring to render instead of reader.reader.read() call should be inside an asynchronous function or handled with a .catch() to properly deal with potential rejections, but since you haven't asked about error handling, I'll focus on the naming issue.reader prop correctly to the Gateway component and that you are not mistakenly using render somewhere else in your code. Also, make sure that the reader object is indeed an instance of a ReadableStreamDefaultReader or has a read method available.Gateway component and the prop being passed to it.Connect.tsx file, you are passing a prop named readable to the Gateway component:Gateway.tsx file, the component is expecting a prop named reader:Connect.tsx to reader when passing it to the Gateway component:Gateway component to accept a prop named readable:reader.read() promise should be handled properly with error catching, but since you haven't asked about that, I'll keep the focus on the prop naming issue.Connect.tsx and Gateway.tsx files. The reader is being passed to the Gateway component as expected.console.log(reader) logging an empty object in the browser console is a common behavior when logging certain types of objects in JavaScript, especially those with internal properties that are not enumerable or are lazy-loaded, like stream readers. This doesn't necessarily indicate a problem with the code itself.reader.read is not a function, this suggests that the reader object at the time of calling read() is not what you expect it to be. It's possible that the reader object is not being passed correctly as a prop or that it's being modified somewhere else in your code.reader object is created outside of the component, which means it's only created once when the module is evaluated. If the WebSocket connection is closed or the reader is released, it won't be recreated when the component re-renders. This could potentially lead to issues if the component expects the reader to be in a certain state.reader is in the correct state when you're trying to call read() on it. Also, ensure that the reader is not being modified or released elsewhere in your code before the read() method is called.Gateway component's props definition. The prop is defined as reader but should be wss based on how you're using it:Uncaught TypeError: Cannot read properties of undefined (reading 'then') suggests that wss.opened is undefined at the time you're trying to access it. This could be due to the WebSocketStream not being in the expected state or the opened property not being available on the wss object.WebSocketStream object is correctly initialized and that the opened property exists and is a promise before you try to call .then() on it.console.log(wss) logging an empty object in the browser console, this is a common behavior in browsers when logging objects that contain complex or non-enumerable properties. It doesn't necessarily indicate a problem with the wss object itself.Gateway component's props definition. The type for the wss prop is incorrectly closed with a > instead of a }. Here's the corrected prop definition:console.log(wss) issue, logging complex objects like WebSocketStream in the browser console can sometimes display as an empty object due to the way the browser console serializes and displays them. This is a common behavior and not specific to Deno.Uncaught TypeError: Cannot read properties of undefined (reading 'then') suggests that wss.opened is not behaving as expected. Since WebSocketStream is an unstable API in Deno, make sure you are using the correct version of Deno where WebSocketStream is supported and that you have enabled the unstable flag if necessary.Promise in a way that should be correct, as you are using .then() to handle the resolved value.Uncaught TypeError: Cannot read properties of undefined (reading 'then') indicates that conn is not a Promise at the time when you're trying to call .then() on it. This could happen if conn is not being passed correctly to the Gateway component or if it's not initialized as a Promise.console.log(conn) logging an empty object in the browser console, this is a common behavior when logging objects with complex or non-enumerable properties, and it doesn't necessarily indicate a problem with the conn object itself.conn prop is being passed correctly to the Gateway component and that it is indeed a Promise that resolves to an object with readable, writable, extensions, and protocol properties.console.log(conn) behavior you're seeing in the browser console, where it logs an empty object, is typical when logging promises or objects with complex structures. This is due to the way browsers serialize and display them and does not necessarily indicate an issue with the conn object itself.Uncaught TypeError: Cannot read properties of undefined (reading 'then') suggests that at the time the code is executed, conn is not recognized as a promise. This could be due to several reasons, such as conn not being properly initialized as a promise or not being passed correctly as a prop.conn prop is correctly provided to the Gateway component and that it is indeed a promise. If conn is supposed to be a promise that resolves to an object with readable, writable, extensions, and protocol properties, you should verify that it is being set and passed as such.conn is not recognized as a promise as it gets logged as a Promise {} object in the vs code console as expected but gets logged as an empty object in the browser console.Promise { <state> }, where <state> is the current state of the promise (pending, fulfilled, or rejected). In contrast, browsers may log a promise as an empty object or with very little information, which can be confusing but is normal behavior.Uncaught TypeError: Cannot read properties of undefined (reading 'then') indicates that at the time the .then() method is being called, conn is undefined. This means that the conn prop may not be passed correctly to the Gateway component, or there is an issue with how the promise is being created or resolved.conn prop is being passed correctly and that it is initialized properly where you expect it to be a promise. If conn is indeed a promise, this error should not occur as long as conn is defined.console.log('message recived') gets logged in vs code console but not in the browser console, and console.log(conn) too gets logged in vs code console as expected but gets logged as an empty object in the browser console. And in the browser console it also throws Uncaught TypeError: Cannot read properties of undefined (reading 'then')console.log('message received') is not being logged in the browser console but is being logged in the VS Code console, it suggests that the code within the .then() block is not being executed in the browser environment. This could be due to the promise conn not being resolved or an error occurring before reaching that point.Uncaught TypeError: Cannot read properties of undefined (reading 'then') indicates that conn is undefined at the time you're trying to call .then() on it in the browser. This could happen if the conn prop is not being passed correctly to the Gateway component or if there's an issue with the promise itself.console.log(conn) logging an empty object in the browser console, this is typical behavior when logging promises or objects with complex structures in the browser, as mentioned previously.conn prop is being passed correctly to the Gateway component.conn is properly initialized and is not undefined.console.log('message received') statement that could prevent it from being reached.WebSocketStream or a promise that resolves to server-side objects to the client-side code, it won't work because those resources cannot be serialized and sent over the network. The browser will not be able to understand or reconstruct those server-side objects, leading to the issues you're experiencing.