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

silentMode in task.ts ignored for spawnNotification if response is a string #3621

Closed
3 tasks done
rain2o opened this issue Sep 25, 2019 · 1 comment
Closed
3 tasks done
Assignees
Labels
question If you are not sure how sth works or want discuss someting
Milestone

Comments

@rain2o
Copy link
Contributor

rain2o commented Sep 25, 2019

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Check our forum:

https://forum.vuestorefront.io/

Is there something you don't understand? What is it? Describe it.

I am not sure if this is a bug, or if this was done intentionally. If it was intentional then I am trying to understand why.

In core/lib/sync/task.ts#131 there is the following if statement. I split it up a lot to try and make it easier to read with all of the ands/ors and parentheses.

if (
    !task.silent
    &&
    jsonResponse.result
    &&
    (
        typeof jsonResponse.result === 'string'
        ||
        (
            (
                (
                    jsonResponse.result.result
                    ||
                    jsonResponse.result.message
                )
                &&
                jsonResponse.result.code !== 'ENOTFOUND'
            )
            &&
            !silentMode
        )
    )
)

The piece in question is the placement of !silentMode. Currently, if jsonResponse.result is a string, then silentMode doesn't matter and the following code is executed, which dispatches the notification to be displayed. The placement of the check on silentMode only matters if the response is not a string.

Why does silentMode not matter for string responses? Was this done for a specific reason, or was it just an oversight in the sea of parentheses that exist in this if statement?

Additional information

This problem was noticed when testing the expiration of the Magento consumer token. If the initial responses are 401, an attempt to refresh the token is performed. Even if this is successful I still receive multiple notifications in the UI stating "Consumer is not authorized to access self" since Magento's initial response was this and it was returned as a string. But the refresh action was successful and those actions were retried successfully, so these notifications are confusing for the user.

@rain2o rain2o added the question If you are not sure how sth works or want discuss someting label Sep 25, 2019
@pkarw
Copy link
Collaborator

pkarw commented Sep 25, 2019

@andrzejewsky or @gibkigonzo please fix it before 1.11rc release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question If you are not sure how sth works or want discuss someting
Projects
None yet
Development

No branches or pull requests

4 participants