Skip to content

Commit 74c7d20

Browse files
heiskrCopilotCopilot
authored
Trim excessive comments in src/frame/middleware (#63259)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: heiskr <1221423+heiskr@users.noreply.github.com> Copilot-Session: 17588eeb-788a-4f82-9d36-b5079fb36521
1 parent e3034ac commit 74c7d20

25 files changed

Lines changed: 77 additions & 148 deletions

‎src/frame/lib/permalink.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ page.permalinks is an array of objects that looks like this:
2929
*/
3030
// String interning pool: deduplicates low-cardinality, highly-repeated values (languageCode, pageVersion)
3131
// across ~975K Permalink instances (~9 languages × ~9 versions × ~65K pages). Because these fields have
32-
// few distinct values (~81 total), the pool stays bounded — do not use intern() for high-cardinality
32+
// few distinct values (~81 total), the pool stays bounded. Do not use intern() for high-cardinality
3333
// fields like relativePath or title, where the pool would grow unbounded and leak memory.
3434
const stringPool = new Map<string, string>()
3535

‎src/frame/lib/read-file-contents.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import fm from './frontmatter'
77
const fmCache =
88
process.env.NODE_ENV === 'production' ? new Map<string, ReturnType<typeof fm>>() : null
99

10-
/**
11-
* Read only the frontmatter from file
12-
*/
1310
export default async function fmfromf(filepath: string): Promise<ReturnType<typeof fm>> {
1411
const cached = fmCache?.get(filepath)
1512
if (cached) return cached

‎src/frame/lib/read-frontmatter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function readFrontmatter(markdown: string, opts: ReadFrontmatterOptions = {}) {
5656
// return:
5757
// property: 'versions.ftp'
5858
//
59-
// The purpose is to help users understand that the error is on the `fpt` key within the `versions` object.
59+
// The purpose is to help users understand that the error is on the `ftp` key within the `versions` object.
6060
// Note if the error is on a top-level FM property like `title`, the `instancePath` will be empty.
6161
const cleanPropertyPath = (
6262
params: Record<string, unknown>,

‎src/frame/lib/strip-outer-tag.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
export function stripOuterTag(html: string): string {
66
if (!html) return ''
77

8-
// Extract opening tag and tag name
98
const openMatch = html.match(/^<([a-z][a-z0-9]*)\b[^>]*>/i)
109
if (!openMatch) return html
1110

‎src/frame/lib/warm-server.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ type WarmServerResult = {
1414
pageMap: Awaited<ReturnType<typeof loadPageMap>>
1515
}
1616

17-
// Instrument these functions so that
18-
// it's wrapped in a timer that reports to Datadog
17+
// Wrap these functions in timers that report to Datadog.
1918
const dog = {
2019
loadUnversionedTree: statsd.asyncTimer(
2120
adaptForTimer(loadUnversionedTree),
@@ -28,7 +27,6 @@ const dog = {
2827
warmServer: statsd.asyncTimer(adaptForTimer(warmServer), 'warm_server'),
2928
}
3029

31-
// For multiple-triggered Promise sharing
3230
let promisedWarmServer: Promise<WarmServerResult> | undefined
3331

3432
async function warmServer(languagesOnly: string[] = []): Promise<WarmServerResult> {
@@ -94,10 +92,6 @@ async function warmServer(languagesOnly: string[] = []): Promise<WarmServerResul
9492
}
9593
}
9694

97-
// Instrument the `warmServer` function so that
98-
// it's wrapped in a timer that reports to Datadog
99-
// dog.warmServer = statsd.asyncTimer(warmServer, 'warm_server') as typeof warmServer
100-
10195
// We only want statistics if the priming needs to occur, so let's wrap the
10296
// real method and return early [without statistics] whenever possible
10397
export default async function warmServerWrapper(languagesOnly: string[] = []) {

‎src/frame/middleware/abort.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export default function abort(req: ExtendedRequest, res: Response, next: NextFun
3636

3737
const abortError = new AbortError('Client closed request', 499, 'ECONNRESET')
3838

39-
// Pass the error to the Express error handler
4039
return next(abortError)
4140
})
4241

‎src/frame/middleware/api.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ router.get('/cookies', (req, res) => {
6363
res.json(cookies)
6464
})
6565

66-
// Handle root /api requests
6766
router.get('/', (req, res) => {
6867
res.status(404).json({ error: `${req.path} not found` })
6968
})

‎src/frame/middleware/cache-control.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function cacheControlFactory(
5353
}
5454
}
5555

56-
// ### These are roughly in order from shortest to longest. ###
56+
// The rest of this file is roughly in order from shortest max age to longest.
5757

5858
// If you do not want caching.
5959
export const noCacheControl = cacheControlFactory(0)

‎src/frame/middleware/context/context.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ export default async function contextualize(
9191
const restDate = new Date(req.context.initialRestVersioningReleaseDate)
9292
req.context.initialRestVersioningReleaseDateLong = restDate.toUTCString().split(' 00:')[0]
9393

94-
// Conditionally add this for non-English pages so what inside the
95-
// `Page.render` method, when it calls out to `renderContentWithFallback`
96-
// it can be able to fall back get original content from English if there's
97-
// some runtime rendering error from the translation.
94+
// Non-English pages need this so that `Page.render`, when it calls
95+
// `renderContentWithFallback`, can fall back to the English content when the
96+
// translation hits a fallback-eligible error (Liquid, autotitle, empty title).
9897
if (req.language !== 'en') {
99-
// The reason this is a function is because most of the time, we don't
100-
// need to know the English equivalent. It only comes into play if a
101-
// translated
98+
// This is a function so the lookup only happens when a translated page
99+
// actually needs to fall back. Most requests never need it.
102100
req.context.getEnglishPage = (ctx) => {
103101
if (!ctx.enPage) {
104102
const { page } = ctx

‎src/frame/middleware/context/current-product-tree.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function currentProductTree(
4949
req.context,
5050
)
5151
// Now make an even slimmer version that excludes all hidden pages.
52-
// This is i used for sidebars.
52+
// This is used for sidebars.
5353
req.context.currentProductTreeTitlesExcludeHidden = excludeHidden(
5454
req.context.currentProductTreeTitles,
5555
)

0 commit comments

Comments
 (0)