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

Agent Server not closing after tests #188

Closed
gswalden opened this issue Nov 10, 2017 · 3 comments
Closed

Agent Server not closing after tests #188

gswalden opened this issue Nov 10, 2017 · 3 comments

Comments

@gswalden
Copy link
Contributor

gswalden commented Nov 10, 2017

Closely related to #178

Setup:

npm install chai chaijs/chai-http#master

Code that exits:

const server = require('http').createServer((req, res) => {
  res.end('Hello World!');
});

const chai = require('chai');
chai.use(require('chai-http'));
const req = chai.request(server);
req.get('/').then(res => {
  console.log(res.text);
});

Code that hangs:

const server = require('http').createServer((req, res) => {
  res.end('Hello World!');
});

const chai = require('chai');
chai.use(require('chai-http'));
const agent = chai.request.agent(server);
agent.get('/').then(res => {
  console.log(res.text);
});

Valid as of cee5dbd.

@keithamus
Copy link
Member

Thanks for issue @gswalden

I wasn't sure if it made sense to auto-close the server for agent, as it is used to store cookie data and made subsequent requests with that data. (Ideally servers should be stateless but this felt like less of a footgun than auto closing a server). If you disagree with this decision I'd love to hear more about your usecase

@gswalden
Copy link
Contributor Author

Understood, if it's a design decision I can't say I have an issue. I will add a note to the README to close this out.

gswalden added a commit to gswalden/chai-http that referenced this issue Nov 15, 2017
@keithamus
Copy link
Member

Thanks @gswalden 👍

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