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

Some beforeRequest edited options are discarded #1293

Merged
merged 3 commits into from May 31, 2020
Merged

Some beforeRequest edited options are discarded #1293

merged 3 commits into from May 31, 2020

Conversation

Giotino
Copy link
Collaborator

@Giotino Giotino commented May 27, 2020

Currently he edits of options.agent and options.url made in beforeRequest are discarded.

This PR simply read agent and url after beforeRequest hooks.

Checklist

  • I have read the documentation.
  • I have included a pull request description of my changes.
  • I have included some tests.

Fixes #1292

@Giotino
Copy link
Collaborator Author

Giotino commented May 28, 2020

Also i wanted to talk about the "unix socket url parsing" before the request.

Documentation for beforeRequest:

Got will make no further changes to the request before it is sent

But this code is modifying some options, after beforeRequest but before the request.
https://github.com/sindresorhus/got/blob/master/source/core/index.ts#L1360,L1372

I think this code should be moved before beforeRequest.

@szmarczak
Copy link
Collaborator

szmarczak commented May 28, 2020

I think this code should be moved before beforeRequest.

No, it should stay where it is. It just translates unix hostname to Node.js native options.

@szmarczak
Copy link
Collaborator

https://travis-ci.com/github/sindresorhus/got/jobs/340837947#L756

$ node --version
v14.3.0

...

  ✖ Timed out while running tests
  1 tests were pending in test/http.ts
  ◌ http.ts › throws an error if the server aborted the request

Can you figure out why it fails please?

@Giotino
Copy link
Collaborator Author

Giotino commented May 28, 2020

https://travis-ci.com/github/sindresorhus/got/jobs/340837947#L756

$ node --version
v14.3.0

...

  ✖ Timed out while running tests
  1 tests were pending in test/http.ts
  ◌ http.ts › throws an error if the server aborted the request

Can you figure out why it fails please?

Even the master branch is failing the same test, for the same reason.
I'm trying to figure out why.

@Giotino
Copy link
Collaborator Author

Giotino commented May 28, 2020

By doing some test it seems to happen only with Node.JS >= 14.3.0
Node.JS 14.2.0: 22 tests passed (only http test were run)

@Giotino
Copy link
Collaborator Author

Giotino commented May 28, 2020

These Node.JS commits (merged into 14.3.0) could be relevant to this issue:
nodejs/node@b634d4b000
nodejs/node@cc5c8e039d

@szmarczak szmarczak merged commit d8c00cf into sindresorhus:master May 31, 2020
@Giotino Giotino deleted the issue-1292 branch June 1, 2020 17:32
szmarczak pushed a commit to jaulz/got that referenced this pull request Jul 6, 2020
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.

Can't use agent in beforeHook
2 participants