Skip to content

Commit faea866

Browse files
authored
Merge branch 'main' into repo-sync
2 parents 88f8d65 + bfb516c commit faea866

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

middleware/abort.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import statsd from '../lib/statsd.js'
2+
13
export default function abort(req, res, next) {
24
// If the client aborts the connection, send an error
35
req.once('aborted', () => {
@@ -7,6 +9,18 @@ export default function abort(req, res, next) {
79
}
810
// NOTE: Node.js will also automatically set `req.aborted = true`
911

12+
const incrementTags = []
13+
// Be careful with depending on attributes set on the `req` because
14+
// under certain conditions the contextualizers might not yet have
15+
// had a chance to run.
16+
if (req.pagePath) {
17+
incrementTags.push(`path:${req.pagePath}`)
18+
}
19+
if (req.context?.currentCategory) {
20+
incrementTags.push(`product:${req.context.currentCategory}`)
21+
}
22+
statsd.increment('middleware.abort', 1, incrementTags)
23+
1024
const abortError = new Error('Client closed request')
1125
abortError.statusCode = 499
1226
abortError.code = 'ECONNRESET'

middleware/timeout.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import timeout from 'express-timeout-handler'
22

3+
import statsd from '../lib/statsd.js'
4+
35
// Heroku router requests timeout after 30 seconds. We should stop them earlier!
46
const maxRequestTimeout = parseInt(process.env.REQUEST_TIMEOUT, 10) || 10000
57

@@ -14,6 +16,18 @@ export default timeout.handler({
1416
disable: [],
1517

1618
onTimeout: function (req, res, next) {
19+
const incrementTags = []
20+
// Be careful with depending on attributes set on the `req` because
21+
// under certain conditions the contextualizers might not yet have
22+
// had a chance to run.
23+
if (req.pagePath) {
24+
incrementTags.push(`path:${req.pagePath}`)
25+
}
26+
if (req.context?.currentCategory) {
27+
incrementTags.push(`product:${req.context.currentCategory}`)
28+
}
29+
statsd.increment('middleware.timeout', 1, incrementTags)
30+
1731
// Create a custom timeout error
1832
const timeoutError = new Error('Request timed out')
1933
timeoutError.statusCode = 503

stylesheets/syntax-highlighting.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ from https://unpkg.com/highlight.js@9.15.8/styles/github.css
3333
.hljs-section,
3434
.hljs-selector-id {
3535
color: var(--color-prettylights-syntax-markup-heading);
36+
}
37+
38+
.hljs-section {
3639
font-weight: bold;
3740
}
3841

0 commit comments

Comments
 (0)