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

Make sure continuations are called only once in Relay code #3

Merged
merged 4 commits into from
Nov 2, 2022
Merged

Make sure continuations are called only once in Relay code #3

merged 4 commits into from
Nov 2, 2022

Conversation

ismyhc
Copy link
Contributor

@ismyhc ismyhc commented Nov 1, 2022

Hey! I believe I have fixed the issues I found where the sockets would crash after some time when the socket was disconnected. I hope Im not stepping on your toes. Just wanted to contribute what has fixed the issues for me so far :)

Basically, in the connect function where it was using the async wrapping function, continuation was being called multiple times. I removed that handled on disconnect a bit differently.

Also, I removed the async wrapping function from disconnect as the onDisconnect closure was already being handled in the connect function.

Copy link
Owner

@cnixbtc cnixbtc left a comment

Choose a reason for hiding this comment

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

Awesome thanks for submitting this fix @ismyhc! 🎉

You're not stepping on anyone's toes here, quite the contrary. I'm happy that you find the project useful.

Code looks good, just a couple minor questions from my side. Let me know what you think!

Sources/NostrKit/Relay.swift Show resolved Hide resolved
Sources/NostrKit/Relay.swift Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@cnixbtc cnixbtc linked an issue Nov 2, 2022 that may be closed by this pull request
@cnixbtc cnixbtc changed the title Fix issues where async's continuation was getting called multiple times causing crash Make sure continuation is called only once in Relay Nov 2, 2022
@cnixbtc cnixbtc changed the title Make sure continuation is called only once in Relay Make sure continuations are called only once in Relay Nov 2, 2022
@cnixbtc cnixbtc changed the title Make sure continuations are called only once in Relay Make sure continuations are called only once in Relay code Nov 2, 2022
@ismyhc
Copy link
Contributor Author

ismyhc commented Nov 2, 2022

@cnixbtc I also added Equatable to EventKind so that I could do comparisons on the enum as well as making the properties of EventFilter public so that the could be accessed. I need this when handing the EOSE event so I could figure out what type of subscription filter was finished.

@cnixbtc cnixbtc merged commit c7a2403 into cnixbtc:master Nov 2, 2022
@cnixbtc
Copy link
Owner

cnixbtc commented Nov 2, 2022

Cool, thanks for the help @ismyhc! I'll remove the relay code as discussed in #2 and do a fresh release then. Let me know if you discover anything else that's not working the way it should.

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.

Fatal error: SWIFT TASK CONTINUATION MISUSE
2 participants