Skip to content
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

Issue with nightly rust and specific rust flags #12

Open
mhchia opened this issue Sep 6, 2023 · 2 comments
Open

Issue with nightly rust and specific rust flags #12

mhchia opened this issue Sep 6, 2023 · 2 comments

Comments

@mhchia
Copy link

mhchia commented Sep 6, 2023

Description

I've encountered an issue with the library when using the nightly Rust version in conjunction with the rustflags +atomics,+bulk-memory,+mutable-globals.

Here's the relevant code snippet:

    let (mut ws_meta, mut ws_stream) = WsMeta::connect(ws_server_url, None).await
        .expect_throw("Assumed the client ws connection would succeed");
    let mut io_stream = ws_stream.into_io();
    let message = b"Hello from browser".to_vec();
    io_stream
        .write(&message).await
        .expect_throw("Failed to write to websocket");

While attempting to write to a websocket (io_stream), the operation fails.

Environment

OS: macOS 12.6
cargo: 1.68.0-nightly (70898e522 2022-12-05)
rustc: 1.68.0-nightly (bdb07a8ec 2022-12-11)
Browser: Chrome Version 116.0.5845.140 (Official Build) (x86_64)

Reproduction Steps

For a detailed step-by-step reproduction guide, please refer to this repository.

I'd greatly appreciate any feedback, solutions, or clarifications regarding this issue.

@mhchia mhchia changed the title Issue with ws-stream-wasm and specific Rust flags Issue with nightly rust and specific rust flags Sep 6, 2023
@najamelan
Copy link
Owner

Thanks for reporting. I'll try to address this this weekend.

@mhchia
Copy link
Author

mhchia commented Sep 8, 2023

Just an update on our end: my colleague found this line failed

WsMessage::Binary( d ) => self.ws.send_with_u8_array( &d ).map_err( |_| WsErr::ConnectionNotOpen )? ,

If the line is replaced by

WsMessage::Binary(d) => {
	let buffer = ArrayBuffer::new(
		d.len()
		.try_into()
		.expect("Message was too large to be sent."),
	);
	Uint8Array::new(&buffer).copy_from(d.as_slice());
	self.ws
		.send_with_array_buffer(&buffer)
		.map_err(|_| WsErr::ConnectionNotOpen)?
}

, it works. However, we then encountered a oom issue with our application

image

I was guessing it is related to memory leaking, for example, buffer is not gc'ed and too many writes may end up using up the memory. But it's just my suspicion and I haven't verified it and may be wrong.

Hope these information will be helpful 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants