File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,20 @@ export function queriesReducer(
9090 state . deletedQueries . add ( action . payload . path )
9191 return state
9292 }
93+ case `DELETED_STALE_PAGE_DATA_FILES` : {
94+ // this action is a hack/hot fix
95+ // it should be removed/reverted when we start persisting pages state
96+ for ( const queryId of action . payload . pagePathsToClear ) {
97+ for ( const component of state . trackedComponents . values ( ) ) {
98+ component . pages . delete ( queryId )
99+ }
100+ state = clearNodeDependencies ( state , queryId )
101+ state = clearConnectionDependencies ( state , queryId )
102+ state . trackedQueries . delete ( queryId )
103+ }
104+
105+ return state
106+ }
93107 case `API_FINISHED` : {
94108 if ( action . payload . apiName !== `createPages` ) {
95109 return state
Original file line number Diff line number Diff line change @@ -352,6 +352,7 @@ export type ActionsUnion =
352352 | IDisableTypeInferenceAction
353353 | ISetProgramAction
354354 | ISetProgramExtensions
355+ | IDeletedStalePageDataFiles
355356
356357export interface IApiFinishedAction {
357358 type : `API_FINISHED`
@@ -804,3 +805,10 @@ interface ISetProgramExtensions {
804805 type : `SET_PROGRAM_EXTENSIONS`
805806 payload : Array < string >
806807}
808+
809+ interface IDeletedStalePageDataFiles {
810+ type : `DELETED_STALE_PAGE_DATA_FILES`
811+ payload : {
812+ pagePathsToClear : Set < string >
813+ }
814+ }
Original file line number Diff line number Diff line change @@ -256,10 +256,20 @@ export async function handleStalePageData(): Promise<void> {
256256 } )
257257
258258 const deletionPromises : Array < Promise < void > > = [ ]
259- pageDataFilesFromPreviousBuilds . forEach ( pageDataFilePath => {
259+ const pagePathsToClear = new Set < string > ( )
260+ for ( const pageDataFilePath of pageDataFilesFromPreviousBuilds ) {
260261 if ( ! expectedPageDataFiles . has ( pageDataFilePath ) ) {
262+ const stalePageDataContent = await fs . readJson ( pageDataFilePath )
263+ pagePathsToClear . add ( stalePageDataContent . path )
261264 deletionPromises . push ( fs . remove ( pageDataFilePath ) )
262265 }
266+ }
267+
268+ store . dispatch ( {
269+ type : `DELETED_STALE_PAGE_DATA_FILES` ,
270+ payload : {
271+ pagePathsToClear,
272+ } ,
263273 } )
264274
265275 await Promise . all ( deletionPromises )
You can’t perform that action at this time.
0 commit comments