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

fix: websocket outbound transport #1788

Merged

Conversation

auer-martin
Copy link
Contributor

@auer-martin auer-martin commented Mar 6, 2024

The previous approach was only possible in Node.
The websocket implementation of RN follows this specification. https://developer.mozilla.org/en-US/docs/Web/API/WebSocket.
The Promise was therefore never resolved as the callback does not exist.

// We can close the socket as it shouldn't return messages anymore
// make sure to use the socket in a manner that is compliant with the https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
// (React Native) and https://github.com/websockets/ws (NodeJs)
socket.send(Buffer.from(JSON.stringify(payload)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We technically could send just a string instead of a buffer with both these interfaces, but it should not matter that much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the method sync in RN? And if we don't provide a callback, is it sync in NodeJS as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't checked it, but there is likely an overload to not provide a callback as you don't have to handle the res/err if you don't want. But yeah it would be good to do a test run with this in both environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fine. It's also the behavior that was there up until 2-3 weeks ago.

@genaris
Copy link
Contributor

genaris commented Mar 6, 2024

Oh that API difference is unfortunate! This error handling was added recently to improve the test suites. Not sure if removing it will affect a lot (because there were other improvements done by @TimoGlastra at the same time), but if it does we can create a TestWsOutboundTransporter or so to manage it.

That being said, if WebSocket API differs in each platform, probably we should look at making a dedicated implementation for each (like we do for inbound transports). The good thing about such idea is that the infamous AgentDependencies object may become smaller, since we won't need a WebSocketClass: if later on we do the same with HttpOutboundTransport, we can remove fetch and if we feel brave enough to move FileSystem dependency to AnonCreds (where it is actually used, mainly for tails files), the only remaining dependency would be the EventEmitter... Just thinking! 🤔

@auer-martin auer-martin marked this pull request as ready for review March 6, 2024 12:54
@TimoGlastra TimoGlastra merged commit ed06d00 into openwallet-foundation:main Mar 8, 2024
13 checks passed
auer-martin added a commit to auer-martin/aries-framework-javascript that referenced this pull request Mar 12, 2024
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

Successfully merging this pull request may close these issues.

4 participants