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

Improve feedback when non-suspending function included in RpcService #231

Open
chris-hatton opened this issue Nov 15, 2024 · 1 comment
Open
Assignees
Labels
feature New feature or request

Comments

@chris-hatton
Copy link

chris-hatton commented Nov 15, 2024

By their nature; all member-functions of RpcService implementations should be suspending.

During development, it may be a common mistake to omit suspend, in which case the developer-user is faced with a potentially confusing error at compile time:

e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: /Users/user/Projects/project/shared/src/commonMain/kotlin/com/project/shared/domain/service/SomeService.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:47)
...
<long stack trace>

Describe the solution you'd like
Compiler plugin or KSP part of kotlinx.rpc should detect the presence of non suspend functions and throw a more meaningful error e.g:

The function 'getUser' in com.company.project.service.UserService is not suspending, only suspending functions are allowed in RPC service implementations.
@chris-hatton chris-hatton added the feature New feature or request label Nov 15, 2024
@Mr3zee
Copy link
Collaborator

Mr3zee commented Nov 18, 2024

Hey, @chris-hatton !
Thanks for suggestion! We are planning to introduce more user friendly checkers, including this one as one for the most needed

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

No branches or pull requests

2 participants