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

Migrate current wasi-sockets TCP impl to worker thread #315

Closed
4 of 5 tasks
manekinekko opened this issue Dec 15, 2023 · 13 comments
Closed
4 of 5 tasks

Migrate current wasi-sockets TCP impl to worker thread #315

manekinekko opened this issue Dec 15, 2023 · 13 comments
Assignees
Labels
priority: high wasi-preview2 This issue is about the Wasi Preview 2 API

Comments

@manekinekko
Copy link
Collaborator

manekinekko commented Dec 15, 2023

  • preview2_tcp_bind
  • preview2_tcp_sockopts
  • preview2_tcp_states
  • preview2_tcp_connect
  • preview2_tcp_sample_application

Closes #154

@manekinekko
Copy link
Collaborator Author

Currently, running cargo test preview2_tcp_sample_application will block and timeout on preview2_tcp_sample_application.rs#L33:

let data = input.blocking_read(first_message.len() as u64).unwrap();

@guybedford any idea what could trigger a timeout on stream.read() call?

@guybedford
Copy link
Collaborator

@manekinekko one common need we have when creating streams is to ensure that the end event triggers the readable event, since we always block on the readable event when reading streams. See eg https://github.com/bytecodealliance/jco/blob/main/packages/preview2-shim/lib/io/worker-thread.js#L432. That's the first thing that comes to mind here, although it could well be something else.

@squillace
Copy link

@guybedford @manekinekko if you think I'm letting you get through the day without closing this, you're nuts.

@manekinekko
Copy link
Collaborator Author

manekinekko commented Jan 4, 2024

Thanks @guybedford I am gonna try that.

@manekinekko
Copy link
Collaborator Author

@squillace we are working on it. We just need one more day :P

@manekinekko
Copy link
Collaborator Author

so, the stream.on("end", () => void stream.emit("readable")); workaround didn't work. I am investigating others options. cc @guybedford

@squillace
Copy link

https://www.youtube.com/watch?v=zKVq-P3z5Vg&t=1s.

@manekinekko
Copy link
Collaborator Author

manekinekko commented Jan 4, 2024

OMG! Now I am listening to Phil Collins all day long!

@squillace
Copy link

https://tenor.com/T9CZ.gif

@manekinekko
Copy link
Collaborator Author

@guybedford after investigation, it seems that this promise never resolve, which then make the call to block. Any clue how to debug this?

unfinishedPolls.get(
handle(INPUT_STREAM_SUBSCRIBE | (call & CALL_TYPE_MASK), id)
)

@guybedford
Copy link
Collaborator

I'm working on the TCP calls now, starting with connect streams. Should have a listen / accept flow working early next week, but there's a lot to do here.

@guybedford
Copy link
Collaborator

@manekinekko I managed to get basic initial listen and accept supported working in #330. Still a bunch of edge cases to work through, but if you're interested in the implementation approach you can find it there.

@guybedford
Copy link
Collaborator

TCP implementation now passing all tests as of #330!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high wasi-preview2 This issue is about the Wasi Preview 2 API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants