isPathVisible shares one construction-mode read per list
MCP and search call it once per result; React cache doesn't dedupe in route handlers, so a 50-result list read Site Settings 300 times. Concurrent calls now share one in-flight read per locale (6 reads). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d45175739f
commit
54c9d3ec10
@@ -118,6 +118,16 @@ describe('under construction — Site Settings → createPageRoute', () => {
|
||||
expect(await rpc('get_page', { path: '/pl/o-nas' })).toMatch(/No page found/)
|
||||
expect(await rpc('search_content', { locale: 'pl', query: 'nas' })).not.toContain('/pl/o-nas')
|
||||
|
||||
// a whole list shares one construction-mode read (React cache doesn't dedupe in route handlers)
|
||||
const readsFor = async (n: number) => {
|
||||
const spy = vi.spyOn(payload, 'findGlobal')
|
||||
await Promise.all(Array.from({ length: n }, (_, i) => helpers.isPathVisible(`/pl/p-${i}`, 'pl')))
|
||||
const count = spy.mock.calls.length
|
||||
spy.mockRestore()
|
||||
return count
|
||||
}
|
||||
expect(await readsFor(50)).toBe(await readsFor(1))
|
||||
|
||||
expect(await helpers.isPathVisible('/pl/o-nas', 'pl')).toBe(false)
|
||||
expect(await helpers.isPathVisible('/pl/brief', 'pl')).toBe(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user