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

FP-2988: Can't create Callback from node subscriber port "+" button #372

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

quirinpa
Copy link
Contributor

@quirinpa quirinpa commented Nov 12, 2024

  • FP-2988: Can't create Callback from node subscriber port "+" button

@quirinpa quirinpa self-assigned this Nov 12, 2024
@quirinpa quirinpa requested a review from a team as a code owner November 12, 2024 10:58
Copy link
Contributor

@manuelnogueiramov manuelnogueiramov left a comment

Choose a reason for hiding this comment

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

I think the solution is quite like what you've done, but I'm afraid this way it might cause a racing condition. Having 2 promises running side by side and the last one is dependent on the first. I would suggest using async await here, this way we know that the promises are called when they are supposed.

@quirinpa
Copy link
Contributor Author

quirinpa commented Nov 22, 2024

I would agree with that, Manuel.

Are we ensuring that the promise only resolves if the action is completed?

@manuelnogueiramov
Copy link
Contributor

I would agree with that, Manuel.

Are we ensuring that the promise only resolves if the action is completed?

Didn't understand what you meant here.

@quirinpa
Copy link
Contributor Author

I meant if it was an asynchronous action, I was asking if we were ensuring that it'd only resolve on completion.

But I looked into it and saw that it wasn't an asynchronous call. So I think your comment does not apply.

@manuelnogueiramov
Copy link
Contributor

I meant if it was an asynchronous action, I was asking if we were ensuring that it'd only resolve on completion.

But I looked into it and saw that it wasn't an asynchronous call. So I think your comment does not apply.

call returns a promise. So, yes it's an asynchronous call. Which means that in some weird case CREATE can finish after the SAVE, which will cause errors. This can be simply fixed by adding async await here

      const handleNewCallback = useCallback( async (defaultMsg, ioConfigName, portName) => {
      const scope = CallbackModel.SCOPE;
      const tempName = "new_callback";
      await call(PLUGINS.DOC_MANAGER.NAME, PLUGINS.DOC_MANAGER.CALL.CREATE, {
        scope,
        name: tempName,
      });
      await call(

@quirinpa
Copy link
Contributor Author

quirinpa commented Dec 11, 2024

Even though call returns a promise (in some instances, at least), which it has to to ensure that remix plugin method calling mechanism supports async methods and promises, it doesn't necessarily mean that we have to use an await there.

The code of the function is synchronous. The call implementation most probably calls the function synchronously and returns its result, which might be a promise, or not.

Not having await there doesn't break anything. And adding it might. I don't have indefinite time for tasks, so please, consider spending less time holding my tasks. I don't pay you with the same coin and would appreciate that you stopped doing that.

@diasnad
Copy link
Collaborator

diasnad commented Dec 12, 2024

Did you test both options to see if any would bring regressions?

@diasnad diasnad self-requested a review December 12, 2024 15:45
@manuelnogueiramov
Copy link
Contributor

What issues could adding an await there, that would in fact make sure that we only run the next code after we get the promise, can happen? What am I overlooking?

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.

3 participants