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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: action server types #831

Merged
merged 4 commits into from Jan 12, 2022

Conversation

JGAntunes
Copy link
Contributor

Public API Changes

Changes for the TS types for:

  • ExecuteCallback for the action server
  • GoalCallback for the action server

Description

Both of these callbacks seem to have wrong types setup. The first one should return a Promise which is then resolved in:

As for the GoalCallback type as per the docs:

  • "The purpose of the goal callback is to decide if a new goal should be accepted or rejected. The callback should take the goal request message as a parameter and must return a GoalResponse value. "

And based on the code:

I've tested out both of these changes in a local project and they work as expected 馃憤

@coveralls
Copy link

coveralls commented Jan 7, 2022

Coverage Status

Coverage increased (+0.07%) to 90.544% when pulling 88727ec on JGAntunes:fix/action-server-types into 73f4036 on RobotWebTools:develop.

@wayneparrott wayneparrott self-requested a review January 7, 2022 14:31
wayneparrott
wayneparrott previously approved these changes Jan 7, 2022
@wayneparrott wayneparrott dismissed their stale review January 7, 2022 15:43

premature approval

@wayneparrott
Copy link
Collaborator

@JGAntunes would you also review test/test-action-server.js as I believe there is some inconsistency with executioncallback.

@fampinheiro
Copy link
Contributor

fampinheiro commented Jan 7, 2022

@wayneparrott I reverted the type change. I expanded it to accept a callback, the callback returns the previous type or a promise that resolves for that type.

Let me know if you are okay with this change.

@wayneparrott
Copy link
Collaborator

@JGAntunes @fampinheiro appreciate you identifying the callback return type inconsistencies. Additionally in server.js I noticed that cancelCallback is awaited on yet the defaltCancelCallback fn does not return a promise. This leads me to believe that the original coder is attempting to account for the case where the executionCallback and cancelCallback functions could be long running async operations. Thus I believe cancelCallback definition should be modified similarly to your proposed modification of the exeutionCallback return type of Promise<ActionResult<T>> | ActionResult<T>. Something like this:

type CancelCallback = () => CancelResponse | Promise<CancelResponse>;

Let's loop @minggangw and others that may know the action api better than me for their thoughts.

@minggangw
Copy link
Member

Thus I believe cancelCallback definition should be modified similarly to your proposed modification of the exeutionCallback return type of Promise<ActionResult> | ActionResult.

I agree, we need to change this accordingly, and it can be separated into another PR, thanks!

Copy link
Member

@minggangw minggangw left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, @wayneparrott pls help to merge it if we decide to submit another PR to resolve the comments.

@wayneparrott
Copy link
Collaborator

@JGAntunes again thx for identifying this issue and the suggested fix. The fix LGTM. Are you able to submit a similar fix for the cancelCallback? If no, I'll open a separate PR.

@JGAntunes
Copy link
Contributor Author

Hey @wayneparrott 馃憢 I can look into it today 馃憤

@wayneparrott
Copy link
Collaborator

@JGAntunes no problem. I decided to move forward and merge this PR. I'll open a 2nd PR for the cancelCallback change.

@wayneparrott wayneparrott merged commit 8d23878 into RobotWebTools:develop Jan 12, 2022
minggangw pushed a commit that referenced this pull request Apr 2, 2022
* fix: ExecuteCallback and GoalCallback definitions
* fix register execute callback return

Co-authored-by: Filipe Pinheiro <dev@fampinheiro.dev>
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.

None yet

5 participants