Unverified Commit 4bed0726 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Return a conflict for stale Request Insights history cursors

Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
parent d9797d17
...@@ -406,7 +406,9 @@ class RequestInsightsJournal { ...@@ -406,7 +406,9 @@ class RequestInsightsJournal {
} }
} }
export class StaleRequestInsightsHistoryCursorError extends Error {} export class StaleRequestInsightsHistoryCursorError extends Error {
name = 'StaleRequestInsightsHistoryCursorError'
}
type JournalRegistry = { type JournalRegistry = {
configured?: RequestInsightsJournal configured?: RequestInsightsJournal
......
...@@ -1066,7 +1066,10 @@ describe('request insights', () => { ...@@ -1066,7 +1066,10 @@ describe('request insights', () => {
getRequestInsightsHistory(distDir, { getRequestInsightsHistory(distDir, {
cursor: firstPage.nextCursor, cursor: firstPage.nextCursor,
}) })
).rejects.toBeInstanceOf(StaleRequestInsightsHistoryCursorError) ).rejects.toMatchObject({
name: 'StaleRequestInsightsHistoryCursorError',
})
expect(new StaleRequestInsightsHistoryCursorError()).toBeInstanceOf(Error)
await resetRequestInsightsJournalForTest() await resetRequestInsightsJournalForTest()
await rm(distDir, { recursive: true, force: true }) await rm(distDir, { recursive: true, force: true })
......
...@@ -230,6 +230,20 @@ describe('request insights', () => { ...@@ -230,6 +230,20 @@ describe('request insights', () => {
}) })
}) })
it('returns a conflict for a history cursor from an old session', async () => {
const cursor = Buffer.from(
JSON.stringify({
sessionId: 'old-session',
generation: 0,
beforeSequence: 1,
})
).toString('base64url')
const response = await next.fetch(
`/_next/development/request-insights?view=history&cursor=${cursor}`
)
expect(response.status).toBe(409)
})
it('rejects history overlap lookups larger than the completed live window', async () => { it('rejects history overlap lookups larger than the completed live window', async () => {
const params = new URLSearchParams({ view: 'history' }) const params = new URLSearchParams({ view: 'history' })
for (let index = 0; index <= MAX_LIVE_COMPLETED_REQUEST_INSIGHTS; index++) { for (let index = 0; index <= MAX_LIVE_COMPLETED_REQUEST_INSIGHTS; index++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment