Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Website/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const { removeStaleRouteCache } = await import('./lib/removeStaleRouteCache');
await removeStaleRouteCache();
}
}
8 changes: 8 additions & 0 deletions Website/lib/removeStaleRouteCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { rm } from 'fs/promises';
import path from 'path';

// Pages cached on disk by an earlier deployment take precedence over the current build
// and reference static chunks that no longer exist. Remove them before serving requests.
export async function removeStaleRouteCache() {
await rm(path.join(process.cwd(), '.next', 'server', 'route-cache'), { recursive: true, force: true });
}
5 changes: 5 additions & 0 deletions Website/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const nextConfig = {
turbopack: {
root: path.join(__dirname, '..'),
},
experimental: {
// Deployments overwrite the build in place. Pages cached on disk at runtime
// would survive the next deployment and reference static chunks that no longer exist.
isrFlushToDisk: false,
},
async headers() {
return [
{
Expand Down
Loading