Skip to content

Commit

Permalink
Data: recreate listeningStores set for every markListeningStores call (
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Dec 16, 2022
1 parent cd8451d commit 7ab478b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/data/src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getStoreName( storeNameOrDescriptor ) {
export function createRegistry( storeConfigs = {}, parent = null ) {
const stores = {};
const emitter = createEmitter();
const listeningStores = new Set();
let listeningStores = null;

/**
* Global listener called for each store's update.
Expand Down Expand Up @@ -112,7 +112,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
*/
function select( storeNameOrDescriptor ) {
const storeName = getStoreName( storeNameOrDescriptor );
listeningStores.add( storeName );
listeningStores?.add( storeName );
const store = stores[ storeName ];
if ( store ) {
return store.getSelectors();
Expand All @@ -122,11 +122,12 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
}

function __unstableMarkListeningStores( callback, ref ) {
listeningStores.clear();
listeningStores = new Set();
try {
return callback.call( this );
} finally {
ref.current = Array.from( listeningStores );
listeningStores = null;
}
}

Expand All @@ -143,7 +144,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
*/
function resolveSelect( storeNameOrDescriptor ) {
const storeName = getStoreName( storeNameOrDescriptor );
listeningStores.add( storeName );
listeningStores?.add( storeName );
const store = stores[ storeName ];
if ( store ) {
return store.getResolveSelectors();
Expand All @@ -165,7 +166,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
*/
function suspendSelect( storeNameOrDescriptor ) {
const storeName = getStoreName( storeNameOrDescriptor );
listeningStores.add( storeName );
listeningStores?.add( storeName );
const store = stores[ storeName ];
if ( store ) {
return store.getSuspendSelectors();
Expand Down

1 comment on commit 7ab478b

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3713010317
📝 Reported issues:

Please sign in to comment.