question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove legacy error notifications infrastructure in favor of store-based one

See original GitHub issue

The storeErrorNotifications feature flag should be removed and the logic behind it should become the new default, more specifically the only version available.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Part 1: Replace generic errors legacy infrastructure

  1. The principal usage of showErrorNotification should be replaced with a datastore-driven alternative, using the core/site store:
    1. It should receive actions setInternalServerError( error ) and clearInternalServerError() and a selector getInternalServerError(), all of which behave similarly to their *AuthError counterparts in the core/user store.
    2. The usages of showErrorNotification that handle errors after a failed module activation (which is basically almost all usages of that function in total) should use setInternalServerError instead (also see next bullet point for context on how to replace the notifications themselves).
    3. A new InternalServerError component should be implemented in assets/js/components/notifications/ which should display the error notification for getInternalServerError (inspired by logic in the AuthError component), with similar appearance (e.g. title, format etc.) that the notifications from the current usages of showErrorNotification have. That component should then be included in the ErrorNotifications component, on top of the two other components.
  2. The showErrorNotification function and its remaining usages should be completely removed.
    1. The now unused GenericError component should also be removed.

Part 2: Remove legacy error notifications infrastructure

  1. The storeErrorNotifications feature flag should be removed and what’s currently behind it should become the new way to display error notifications.
  2. The legacy ErrorNotification component (sometimes referred to as LegacyErrorNotifications) should no longer be used.
  3. The googlesitekit.ErrorNotification filter and all of its usages should be removed, e.g.:
    1. the legacy ErrorNotification
    2. the relevant logic in the legacy handleWPError function and in assets/js/components/legacy-notifications/index.js

Implementation Brief

Numbering here matches numbering on AC. Refer to AC first

Part 1

1 .i. Create a new datastore assets/js/googlesitekit/data/site/errors.js. Copy relevant actions and selectors from assets/js/googlesitekit/datastore/user/authentication.js but change names and constants (and ignore all the code for storing authentication state. This datastore is much larger)

1 .ii. Follow AC. Some existing calls to showErrorNotification have a second argument e.g.

showErrorNotification( GenericError, {
	id: 'activate-module-error',
	title: __( 'Internal Server Error', 'google-site-kit' ),
	description: error.message,
	format: 'small',
	type: 'win-error',
} );

and another call passes in an instantiated Notification component showErrorNotification( InvalidCredentialsWarning );

The id, title, description, learnMoreURL, and learnMoreLabel change

So copying AuthError we’d want these passed in error.data

  1. iii. Follow IB. Copy like AuthError but pass in the keys above to the inner `Notification component.

  2. i. Follow AC

“The usages of showErrorNotification that handle errors after a failed module activation (which is basically almost all usages of that function in total)” The only other usage of showErrorNotification in assets/js/components/legacy-notifications/data-error.js is to be deleted

Part 2

  1. Remove storeErrorNotifications from feature-flags.json

  2. Remove any usage of this storeErrorNotifications flag from codebase. Not many uses. In Header.js make the component behind the flag always visible. Tests should still pass where previously this was set.

  3. Remove <LegacyErrorNotification/> from Header.js (double-check no more instances)

  4. Do as per AC

Test Coverage

  • Create a assets/js/googlesitekit/data/site/errors.test.js, copying relevant tests from assets/js/googlesitekit/data/site/authentication.test.js
  • Currently assets/js/util/test/showErrorNotification.js contains tests for showErrorNotification. Check that setInternalServerError, clearInternalServerError and getInternalServerError cause corresponding changes in InternalServerError (displayed, not displayed, displays correct message)

Visual Regression Changes

  • Changes not expected

QA Brief

  • Check the new datastore/site/errors store has been created with the following:
    • action: setInternalServerError
    • action: clearInternalServerError
    • selector: getInternalServerError
  • Check that all instances of showErrorNotification have been replaced with dispatches to setInternalServerError
  • Check the storeErrorNotifications flag has been removed from feature-flags.json and from everywhere in the codebase
  • Check the LegacyErrorNotification component has been removed from Header.js and everywhere else in the codebase
  • Check that js tests pass

Changelog entry

  • N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
felixarntzcommented, Jul 7, 2021

@eugene-manuilov @aaemnnosttv Please do not merge this until develop is open towards the 1.38.0 release, since we want to time this to go out together with #1997, #2077, and #2258.

1reaction
danielgentcommented, Jun 24, 2021

@Hazlitte that’s definitely a typo on my behalf 😄 Apologies. Put any more questions in here!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove legacy error notifications infrastructure in favor of store ...
Remove legacy error notifications infrastructure in favor of store-based one - site-kit-wp ... Part 1: Replace generic errors legacy infrastructure.
Read more >
Remove legacy data API and legacy higher-order components ...
1. Remove assets/js/components/data · Remove <CollectModuleData> · Remove legacy dataAPI* props · Go through the consumers of <Root> , find instances where these ......
Read more >
Change existing intelligence in Splunk Enterprise Security
From the Enterprise Security menu bar, select Configure > Data Enrichment > Threat Intelligence Management. Find the intelligence source. Under Status, click ...
Read more >
AWS Solutions Architect Associate SAA-C02 Practice ...
Part 6 in series AWS Solutions Architect Associate SAA-C02 Practice Exam. This part include 65 high quality practice questions and it's free ...
Read more >
Failing over and failing back a pool in Skype for Business Server
In this case, you must fix the Central Management store based on the error messages that you see, and then run this cmdlet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found