Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly handle prematurely closed requests #4772

Merged
Merged
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
8 changes: 3 additions & 5 deletions distributor-node/src/services/httpApi/HttpApiBase.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import cors from 'cors'
import express from 'express'
import * as OpenApiValidator from 'express-openapi-validator'
import { HttpError, OpenApiValidatorOpts } from 'express-openapi-validator/dist/framework/types'
import { ReadonlyConfig } from '../../types/config'
import expressWinston from 'express-winston'
import { Logger } from 'winston'
import { Server } from 'http'
import cors from 'cors'

import { Logger } from 'winston'
import { ReadonlyConfig } from '../../types/config'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type HttpApiRoute = ['get' | 'head' | 'post', string, express.RequestHandler<any>]

Expand All @@ -24,7 +23,6 @@ export abstract class HttpApiBase {
// Fix for express-winston in order to also log prematurely closed requests
res.on('close', () => {
res.locals.prematurelyClosed = !res.writableFinished
res.end()
})
try {
await handler(req, res, next)
Expand Down
Loading