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

replace got with undici #352

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

bjohansebas
Copy link
Member

Unlike what #347 does, got is replaced with undici, avoiding the use of try-catch, with the same result. It might improve the workflow speed, but that's the least important thing (in my opinion).

Copy link

socket-security bot commented Dec 13, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] environment, network 0 1.28 MB matteo.collina

🚮 Removed packages: npm/[email protected]

View full report↗︎

Copy link
Member

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

LGTM! I like the idea of using undici in this scenario 👍

scripts/fetch-iana.js Outdated Show resolved Hide resolved
@UlisesGascon UlisesGascon mentioned this pull request Dec 20, 2024
Co-authored-by: Ulises Gascón <[email protected]>
@UlisesGascon
Copy link
Member

Not sure why the coverage is failing, but does not seems related (IMO) https://github.com/jshttp/mime-db/actions/runs/12635017301/job/35239389864?pr=352

scripts/utils.js Outdated Show resolved Hide resolved
var mime = extractTemplateMime(body)

// add the template as a source
addSource(data, res.url)
Copy link
Member

@jonchurch jonchurch Jan 7, 2025

Choose a reason for hiding this comment

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

Im not sure that we are getting redirects from IANA, but the two previous http clients being used would follow redirects if we got them. So the res.url here was functional in that sense, it would resolve to whatever location the server redirected us to vs the url we initiated a request to.

Something to keep in mind here, if we did get a redirect we'd break or otherwise drop the data. Hopefully we'd notice that in the diff.

Copy link
Member Author

Choose a reason for hiding this comment

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

Undici does not provide the url property, so I had to create a variable and update it manually to replicate the behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

We're also no longer receiving redirects since I changed the URL that was causing the redirect in:

https://github.com/jshttp/mime-db/blob/e7548fb503f2f1015026c09012b47e2abe7a82a6/scripts/fetch-iana.js#L113-115

Copy link
Member

Choose a reason for hiding this comment

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

@jonchurch do you consider this resolved? If so I would like to merge this.

scripts/utils.js Outdated Show resolved Hide resolved
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.

4 participants