Skip to content

Commit 4d21e8c

Browse files
fix(web): bound Next route cache memory (#1594)
* fix(web): bound Next route cache memory * docs: add Next route cache fix to changelog * test(web): update mocks for Next 16.3 types
1 parent f3b61aa commit 4d21e8c

10 files changed

Lines changed: 86 additions & 59 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Fixed
11+
- Upgraded Next.js to 16.3.1 to bound memory retained by high-cardinality dynamic route cache entries. [#1594](https://github.com/sourcebot-dev/sourcebot/pull/1594)
1112
- Fixed memory leak attributed to CodeMirror allocating objects on heap that were never freed. [#1580](https://github.com/sourcebot-dev/sourcebot/pull/1580)
1213
- Kept Git provider credentials out of subprocess arguments and on-disk configuration by using isolated in-memory credential caches. [#1584](https://github.com/sourcebot-dev/sourcebot/pull/1584)
1314

packages/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"micromatch": "^4.0.8",
163163
"minidenticons": "^4.2.1",
164164
"motion": "^12.42.0",
165-
"next": "^16.2.11",
165+
"next": "^16.3.1",
166166
"next-auth": "^5.0.0-beta.32",
167167
"next-navigation-guard": "^0.2.0",
168168
"next-themes": "^0.3.0",

packages/web/src/ee/features/chat/useUnsavedChangesGuard.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ afterEach(() => {
2020
// A minimal underlying App Router for the guard library to wrap. Without an
2121
// outer router there is nothing to intercept, so the guard never engages.
2222
const makeMockRouter = (): AppRouterInstance => ({
23+
bfcacheId: "test",
2324
push: vi.fn(),
2425
replace: vi.fn(),
2526
refresh: vi.fn(),

packages/web/src/features/agents/review-agent/nodes/githubPushPrReviews.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('githubPushPrReviews', () => {
6868

6969
await githubPushPrReviews(octokit, MOCK_PAYLOAD, SINGLE_REVIEW);
7070

71-
const call = octokit.rest.pulls.createReviewComment.mock.calls[0][0];
71+
const call = vi.mocked(octokit.rest.pulls.createReviewComment).mock.calls[0][0];
7272
expect(call).toHaveProperty('line', 10);
7373
expect(call).not.toHaveProperty('start_line');
7474
});
@@ -84,7 +84,7 @@ describe('githubPushPrReviews', () => {
8484

8585
await githubPushPrReviews(octokit, MOCK_PAYLOAD, multiLineReviews);
8686

87-
const call = octokit.rest.pulls.createReviewComment.mock.calls[0][0];
87+
const call = vi.mocked(octokit.rest.pulls.createReviewComment).mock.calls[0][0];
8888
expect(call).toHaveProperty('start_line', 5);
8989
expect(call).toHaveProperty('line', 15);
9090
expect(call).toHaveProperty('start_side', 'RIGHT');

packages/web/src/features/agents/review-agent/nodes/gitlabMrParser.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ const MOCK_MR_API_RESPONSE = {
4848
},
4949
};
5050

51-
function makeMockGitlabClient(allDiffsResult: unknown, mrOverrides: Partial<typeof MOCK_MR_API_RESPONSE> = {}) {
51+
type MockMrApiResponseOverrides = Omit<Partial<typeof MOCK_MR_API_RESPONSE>, 'description'> & {
52+
description?: string | null;
53+
};
54+
55+
function makeMockGitlabClient(allDiffsResult: unknown, mrOverrides: MockMrApiResponseOverrides = {}) {
5256
return {
5357
MergeRequests: {
5458
show: vi.fn().mockResolvedValue({ ...MOCK_MR_API_RESPONSE, ...mrOverrides }),

packages/web/src/features/agents/review-agent/nodes/gitlabPushMrReviews.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('gitlabPushMrReviews', () => {
101101

102102
await gitlabPushMrReviews(client, 101, MOCK_PAYLOAD, SINGLE_REVIEW);
103103

104-
const noteBody = client.MergeRequestNotes.create.mock.calls[0][2] as string;
104+
const noteBody = vi.mocked(client.MergeRequestNotes.create).mock.calls[0][2] as string;
105105
expect(noteBody).toContain('src/foo.ts');
106106
});
107107

@@ -116,7 +116,7 @@ describe('gitlabPushMrReviews', () => {
116116

117117
await gitlabPushMrReviews(client, 101, MOCK_PAYLOAD, multiLineReviews);
118118

119-
const noteBody = client.MergeRequestNotes.create.mock.calls[0][2] as string;
119+
const noteBody = vi.mocked(client.MergeRequestNotes.create).mock.calls[0][2] as string;
120120
expect(noteBody).toContain('10');
121121
expect(noteBody).toContain('20');
122122
expect(noteBody).toContain('Refactor this block');
@@ -272,9 +272,9 @@ describe('gitlabPushMrReviews', () => {
272272

273273
await gitlabPushMrReviews(client, 101, payloadWithDiffs, addedLineReview);
274274

275-
const call = client.MergeRequestDiscussions.create.mock.calls[0][3];
276-
expect(call.position).not.toHaveProperty('oldLine');
277-
expect(call.position.newLine).toBe('2');
275+
const position = vi.mocked(client.MergeRequestDiscussions.create).mock.calls[0]![3]!.position!;
276+
expect(position).not.toHaveProperty('oldLine');
277+
expect(position.newLine).toBe('2');
278278
});
279279

280280
test('uses new path for both oldPath and newPath when old path is /dev/null (added file)', async () => {

packages/web/src/features/git/getFileSourceApi.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('getFileSourceForRepo', () => {
8383

8484
const mockPrisma = {
8585
repo: { findFirst: mockFindFirst },
86-
} as Parameters<typeof getFileSourceForRepo>[1]['prisma'];
86+
} as unknown as Parameters<typeof getFileSourceForRepo>[1]['prisma'];
8787

8888
beforeEach(() => {
8989
vi.clearAllMocks();

packages/web/src/features/mcp/prismaScope.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const user = {
1010
emailVerified: null,
1111
image: null,
1212
sessionVersion: 0,
13+
lastActiveAt: null,
1314
createdAt: new Date('2026-01-01T00:00:00Z'),
1415
updatedAt: new Date('2026-01-01T00:00:00Z'),
1516
accounts: [],

packages/web/src/middleware/withAuth.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,9 @@ describe('getAuthContext', () => {
10531053
userId,
10541054
orgId: MOCK_ORG.id,
10551055
role: OrgRole.MEMBER,
1056+
suspendedAt: null,
1057+
scimExternalId: null,
1058+
lastActiveAt: null,
10561059
});
10571060
setMockHeaders(new Headers({ 'Authorization': 'Bearer sboa_oauthtoken' }));
10581061

@@ -1080,6 +1083,9 @@ describe('getAuthContext', () => {
10801083
userId,
10811084
orgId: MOCK_ORG.id,
10821085
role: OrgRole.MEMBER,
1086+
suspendedAt: null,
1087+
scimExternalId: null,
1088+
lastActiveAt: null,
10831089
});
10841090
setMockHeaders(new Headers({ 'Authorization': 'Bearer sboa_oauthtoken' }));
10851091

@@ -1101,6 +1107,9 @@ describe('getAuthContext', () => {
11011107
userId,
11021108
orgId: MOCK_ORG.id,
11031109
role: OrgRole.MEMBER,
1110+
suspendedAt: null,
1111+
scimExternalId: null,
1112+
lastActiveAt: null,
11041113
});
11051114
prisma.apiKey.findUnique.mockResolvedValue({ ...MOCK_API_KEY, hash: 'apikey', createdById: userId });
11061115
setMockHeaders(new Headers({ 'X-Sourcebot-Api-Key': 'sourcebot-apikey' }));

yarn.lock

Lines changed: 60 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,10 +3714,10 @@ __metadata:
37143714
languageName: node
37153715
linkType: hard
37163716

3717-
"@next/env@npm:16.2.11":
3718-
version: 16.2.11
3719-
resolution: "@next/env@npm:16.2.11"
3720-
checksum: 10c0/fdb5ff54037f5e554c7452a31f745e40a02ea55416b80c9abf5ebb3b6fba54beaa15e080fc8470f9a59b3a0506c7ce775764134256d413f17e17e4f92802cee3
3717+
"@next/env@npm:16.3.1":
3718+
version: 16.3.1
3719+
resolution: "@next/env@npm:16.3.1"
3720+
checksum: 10c0/c2c61e12c31a8d3be6738fc18b4d7c1e6a151336fb386b4eff8961ee0c72cabb33867febe903a2aacf26aed75be9aa77d4947b15c45162fc0279c0f612884f5a
37213721
languageName: node
37223722
linkType: hard
37233723

@@ -3730,58 +3730,58 @@ __metadata:
37303730
languageName: node
37313731
linkType: hard
37323732

3733-
"@next/swc-darwin-arm64@npm:16.2.11":
3734-
version: 16.2.11
3735-
resolution: "@next/swc-darwin-arm64@npm:16.2.11"
3733+
"@next/swc-darwin-arm64@npm:16.3.1":
3734+
version: 16.3.1
3735+
resolution: "@next/swc-darwin-arm64@npm:16.3.1"
37363736
conditions: os=darwin & cpu=arm64
37373737
languageName: node
37383738
linkType: hard
37393739

3740-
"@next/swc-darwin-x64@npm:16.2.11":
3741-
version: 16.2.11
3742-
resolution: "@next/swc-darwin-x64@npm:16.2.11"
3740+
"@next/swc-darwin-x64@npm:16.3.1":
3741+
version: 16.3.1
3742+
resolution: "@next/swc-darwin-x64@npm:16.3.1"
37433743
conditions: os=darwin & cpu=x64
37443744
languageName: node
37453745
linkType: hard
37463746

3747-
"@next/swc-linux-arm64-gnu@npm:16.2.11":
3748-
version: 16.2.11
3749-
resolution: "@next/swc-linux-arm64-gnu@npm:16.2.11"
3747+
"@next/swc-linux-arm64-gnu@npm:16.3.1":
3748+
version: 16.3.1
3749+
resolution: "@next/swc-linux-arm64-gnu@npm:16.3.1"
37503750
conditions: os=linux & cpu=arm64 & libc=glibc
37513751
languageName: node
37523752
linkType: hard
37533753

3754-
"@next/swc-linux-arm64-musl@npm:16.2.11":
3755-
version: 16.2.11
3756-
resolution: "@next/swc-linux-arm64-musl@npm:16.2.11"
3754+
"@next/swc-linux-arm64-musl@npm:16.3.1":
3755+
version: 16.3.1
3756+
resolution: "@next/swc-linux-arm64-musl@npm:16.3.1"
37573757
conditions: os=linux & cpu=arm64 & libc=musl
37583758
languageName: node
37593759
linkType: hard
37603760

3761-
"@next/swc-linux-x64-gnu@npm:16.2.11":
3762-
version: 16.2.11
3763-
resolution: "@next/swc-linux-x64-gnu@npm:16.2.11"
3761+
"@next/swc-linux-x64-gnu@npm:16.3.1":
3762+
version: 16.3.1
3763+
resolution: "@next/swc-linux-x64-gnu@npm:16.3.1"
37643764
conditions: os=linux & cpu=x64 & libc=glibc
37653765
languageName: node
37663766
linkType: hard
37673767

3768-
"@next/swc-linux-x64-musl@npm:16.2.11":
3769-
version: 16.2.11
3770-
resolution: "@next/swc-linux-x64-musl@npm:16.2.11"
3768+
"@next/swc-linux-x64-musl@npm:16.3.1":
3769+
version: 16.3.1
3770+
resolution: "@next/swc-linux-x64-musl@npm:16.3.1"
37713771
conditions: os=linux & cpu=x64 & libc=musl
37723772
languageName: node
37733773
linkType: hard
37743774

3775-
"@next/swc-win32-arm64-msvc@npm:16.2.11":
3776-
version: 16.2.11
3777-
resolution: "@next/swc-win32-arm64-msvc@npm:16.2.11"
3775+
"@next/swc-win32-arm64-msvc@npm:16.3.1":
3776+
version: 16.3.1
3777+
resolution: "@next/swc-win32-arm64-msvc@npm:16.3.1"
37783778
conditions: os=win32 & cpu=arm64
37793779
languageName: node
37803780
linkType: hard
37813781

3782-
"@next/swc-win32-x64-msvc@npm:16.2.11":
3783-
version: 16.2.11
3784-
resolution: "@next/swc-win32-x64-msvc@npm:16.2.11"
3782+
"@next/swc-win32-x64-msvc@npm:16.3.1":
3783+
version: 16.3.1
3784+
resolution: "@next/swc-win32-x64-msvc@npm:16.3.1"
37853785
conditions: os=win32 & cpu=x64
37863786
languageName: node
37873787
linkType: hard
@@ -9069,7 +9069,7 @@ __metadata:
90699069
micromatch: "npm:^4.0.8"
90709070
minidenticons: "npm:^4.2.1"
90719071
motion: "npm:^12.42.0"
9072-
next: "npm:^16.2.11"
9072+
next: "npm:^16.3.1"
90739073
next-auth: "npm:^5.0.0-beta.32"
90749074
next-navigation-guard: "npm:^0.2.0"
90759075
next-themes: "npm:^0.3.0"
@@ -9156,12 +9156,12 @@ __metadata:
91569156
languageName: node
91579157
linkType: hard
91589158

9159-
"@swc/helpers@npm:0.5.15":
9160-
version: 0.5.15
9161-
resolution: "@swc/helpers@npm:0.5.15"
9159+
"@swc/helpers@npm:0.5.23":
9160+
version: 0.5.23
9161+
resolution: "@swc/helpers@npm:0.5.23"
91629162
dependencies:
91639163
tslib: "npm:^2.8.0"
9164-
checksum: 10c0/33002f74f6f885f04c132960835fdfc474186983ea567606db62e86acd0680ca82f34647e8e610f4e1e422d1c16fce729dde22cd3b797ab1fd9061a825dabca4
9164+
checksum: 10c0/02da7b4df465693933ecd4851cc193ec729c309939c8a84eccae5ec0010aafc3894e713b8ef8d13a6ba401759f0e900c88e2dcfef5872c27bb91e70f73275cce
91659165
languageName: node
91669166
linkType: hard
91679167

@@ -18302,24 +18302,24 @@ __metadata:
1830218302
languageName: node
1830318303
linkType: hard
1830418304

18305-
"next@npm:^16.2.11":
18306-
version: 16.2.11
18307-
resolution: "next@npm:16.2.11"
18305+
"next@npm:^16.2.11, next@npm:^16.3.1":
18306+
version: 16.3.1
18307+
resolution: "next@npm:16.3.1"
1830818308
dependencies:
18309-
"@next/env": "npm:16.2.11"
18310-
"@next/swc-darwin-arm64": "npm:16.2.11"
18311-
"@next/swc-darwin-x64": "npm:16.2.11"
18312-
"@next/swc-linux-arm64-gnu": "npm:16.2.11"
18313-
"@next/swc-linux-arm64-musl": "npm:16.2.11"
18314-
"@next/swc-linux-x64-gnu": "npm:16.2.11"
18315-
"@next/swc-linux-x64-musl": "npm:16.2.11"
18316-
"@next/swc-win32-arm64-msvc": "npm:16.2.11"
18317-
"@next/swc-win32-x64-msvc": "npm:16.2.11"
18318-
"@swc/helpers": "npm:0.5.15"
18309+
"@next/env": "npm:16.3.1"
18310+
"@next/swc-darwin-arm64": "npm:16.3.1"
18311+
"@next/swc-darwin-x64": "npm:16.3.1"
18312+
"@next/swc-linux-arm64-gnu": "npm:16.3.1"
18313+
"@next/swc-linux-arm64-musl": "npm:16.3.1"
18314+
"@next/swc-linux-x64-gnu": "npm:16.3.1"
18315+
"@next/swc-linux-x64-musl": "npm:16.3.1"
18316+
"@next/swc-win32-arm64-msvc": "npm:16.3.1"
18317+
"@next/swc-win32-x64-msvc": "npm:16.3.1"
18318+
"@swc/helpers": "npm:0.5.23"
1831918319
baseline-browser-mapping: "npm:^2.9.19"
1832018320
caniuse-lite: "npm:^1.0.30001579"
18321-
postcss: "npm:8.4.31"
18322-
sharp: "npm:^0.34.5"
18321+
postcss: "npm:8.5.23"
18322+
sharp: "npm:^0.35.3"
1832318323
styled-jsx: "npm:5.1.6"
1832418324
peerDependencies:
1832518325
"@opentelemetry/api": ^1.1.0
@@ -18358,7 +18358,7 @@ __metadata:
1835818358
optional: true
1835918359
bin:
1836018360
next: dist/bin/next
18361-
checksum: 10c0/81f85262cf01ad6b4fd4a8be369925dfe206806a33e967733033d7adcf367aa0ba1f911272de6169a3d09315821eddf6b57594337a456ad134ba5aa8870a80b1
18361+
checksum: 10c0/a071c6fdb9d02fc97b520d2c94aacfce693cf1847287129e0eaec42e8715433d925d165b8c800aff102f40820c8cf4a2e0306905d4d9912b5864a16e4f223bf0
1836218362
languageName: node
1836318363
linkType: hard
1836418364

@@ -19395,6 +19395,17 @@ __metadata:
1939519395
languageName: node
1939619396
linkType: hard
1939719397

19398+
"postcss@npm:8.5.23":
19399+
version: 8.5.23
19400+
resolution: "postcss@npm:8.5.23"
19401+
dependencies:
19402+
nanoid: "npm:^3.3.16"
19403+
picocolors: "npm:^1.1.1"
19404+
source-map-js: "npm:^1.2.1"
19405+
checksum: 10c0/ed714e635b330bb42666ecdd0c0b4f30224ded15b0b0052d6bc2b92832f2cf17d1c1141359453f96f0a84f8fbf4c405a74df187f559163b8f31131b2535455aa
19406+
languageName: node
19407+
linkType: hard
19408+
1939819409
"postcss@npm:^8.4.47, postcss@npm:^8.5.12, postcss@npm:^8.5.15":
1939919410
version: 8.5.25
1940019411
resolution: "postcss@npm:8.5.25"

0 commit comments

Comments
 (0)