Skip to content

Commit 92ac830

Browse files
authored
Do not timeout requests during testing (#18206)
* Do not load the timeout middleware during testing * Run the link-check-server in testing mode to avoid loading the timeout middleware * Revert the change to 'package.json' * Also consider GITHUB_ACTIONS to be a testing environment to support the link checkers
1 parent 3b93bb2 commit 92ac830

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

middleware/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ const express = require('express')
22
const instrument = require('../lib/instrument-middleware')
33
const haltOnDroppedConnection = require('./halt-on-dropped-connection')
44

5-
const isDevelopment = process.env.NODE_ENV === 'development'
5+
const { NODE_ENV } = process.env
6+
const isDevelopment = NODE_ENV === 'development'
7+
const isTest = NODE_ENV === 'test' || process.env.GITHUB_ACTIONS === 'true'
68

79
// Catch unhandled promise rejections and passing them to Express's error handler
810
// https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016
@@ -13,7 +15,7 @@ const asyncMiddleware = fn =>
1315

1416
module.exports = function (app) {
1517
// *** Request connection management ***
16-
app.use(require('./timeout'))
18+
if (!isTest) app.use(require('./timeout'))
1719
app.use(require('./abort'))
1820

1921
// *** Development tools ***

0 commit comments

Comments
 (0)