Skip to content

Fix tests: call end on response, not result of writeHead - #543

Open
candrews wants to merge 1 commit into
sockjs:mainfrom
candrews:fix-tests
Open

Fix tests: call end on response, not result of writeHead#543
candrews wants to merge 1 commit into
sockjs:mainfrom
candrews:fix-tests

Conversation

@candrews

@candrews candrews commented Apr 5, 2021

Copy link
Copy Markdown

No description provided.

@candrews

candrews commented Apr 5, 2021

Copy link
Copy Markdown
Author

The failing test is because the test doesn't have access to Travis secure variables:

elif [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ]; then

It would pass if run by the main sockjs-client repo.

@candrews

candrews commented May 3, 2021

Copy link
Copy Markdown
Author

@brycekahle can you please take a look at this PR?

} else {
serve(req, res, function(err) {
var status = err ? err.statusCode : 404;
return res.writeHead(status).end();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res.writeHead returns http.ServerResponse, so the previous code should be OK. The docs even say:

Returns a reference to the ServerResponse, so that calls can be chained.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be... but in reality, the test doesn't pass without the change from this PR.

Have you tried?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which specific test(s) are you referring to?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example from #534
https://travis-ci.org/github/sockjs/sockjs-client/jobs/761021386#L416

And another from #536
https://travis-ci.org/github/sockjs/sockjs-client/jobs/762011841#L431

If you look the builds for some PRs, there are a number of examples.

@auvipy auvipy closed this Feb 12, 2025
@auvipy auvipy reopened this Feb 12, 2025
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

Successfully merging this pull request may close these issues.

3 participants