connect-pause
raw JSON → 0.1.0 verified Sat Apr 25 auth: no javascript maintenance
A Connect/Express middleware for simulating latency during development. Version 0.1.0, last updated in 2013, with no recent releases. It allows pausing all or specific requests by a given number of milliseconds, and optionally returning an error after the delay. Lightweight and simple, it is suitable for debugging but lacks TypeScript support and has not seen recent maintenance.
Common errors
error Cannot find module 'connect-pause' ↓
cause Package not installed or not found in node_modules.
fix
Run 'npm install connect-pause' to install the package.
error TypeError: pause is not a function ↓
cause Incorrect import: using named import instead of default import.
fix
Use 'import pause from 'connect-pause'' or 'const pause = require('connect-pause')'.
error Error: middleware is not a function ↓
cause Passing arguments incorrectly or using the middleware without calling it.
fix
Call pause(ms) to return a middleware function, e.g., app.use(pause(1000)).
Warnings
deprecated Package has not been updated since 2013. ↓
fix Consider using alternative middleware or maintaining the package yourself.
gotcha The error parameter is passed to next(), which Express interprets as an error and may not result in the expected status code. ↓
fix Set the error object's status or use a custom error handler.
gotcha Requires express or connect; not compatible with other frameworks without middleware adaptation. ↓
fix Wrap the middleware for compatibility if needed.
Install
npm install connect-pause yarn add connect-pause pnpm add connect-pause Imports
- default wrong
const pause = require('connect-pause')correctimport pause from 'connect-pause' - default
const pause = require('connect-pause') - pause wrong
import { pause } from 'connect-pause'correctconst pause = require('connect-pause')
Quickstart
import express from 'express';
import pause from 'connect-pause';
const app = express();
app.use(pause(2000)); // pause all requests by 2 seconds
app.get('/', (req, res) => {
res.send('Response after 2 seconds');
});
app.listen(3000, () => console.log('Server running on port 3000'));