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

Seems broken #6

Open
scottc-netflix opened this issue Jan 7, 2020 · 1 comment
Open

Seems broken #6

scottc-netflix opened this issue Jan 7, 2020 · 1 comment

Comments

@scottc-netflix
Copy link

scottc-netflix commented Jan 7, 2020

This library times out the request but then still tries to return the response after the request already timed out. It's possible I'm using it wrong, but docs are very limited so it's hard to tell.

Basically I'm doing something like this:

import { Router } from 'express';
import timeout from 'express-timeout-handler';

const router = new Router();

router.use(timeout.handler({
  timeout: 60000,
  onTimeout: (req, res) => {
    res.status(503).send('Service timed out');
  }
});

router.use('/myEndpoint', timeout.set(5000), bodyParser.json(), (req, res) => {
  // make a call to another service here and return result
});

I have an unhandledReject handler that picks up this:

UNHANDLED REJECTION: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client.

@Oligrand
Copy link
Contributor

Hi @scottc-netflix . It's not possible to replicate this unless you show us what happens inside the /myEndpoint handler. More specifically you need to show us all methods which are accessed on the res object (for example doing res.json(...)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants