Skip to content

fix: remove got as a dependency, replace with fetch #6468

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

Merged
merged 7 commits into from
Jun 25, 2025

Conversation

mrstork
Copy link
Contributor

@mrstork mrstork commented Jun 13, 2025

Summary

Replace usage of got with native fetch calls instead
Makes more packages dev only, thus shrinking the overall package size.


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@mrstork mrstork force-pushed the remove-got-dependency branch 2 times, most recently from ad2073f to b98179c Compare June 24, 2025 00:45
Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

1 similar comment
Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@@ -4,7 +4,7 @@ import { promisify } from 'util'

import getStream from 'get-stream'

type Handler = { path: string; response: unknown; status?: number }
type Handler = { path: string; response?: object; status?: number; wait?: number }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait is already used in the test suite and in this file, it just wasn't listed in these types

@@ -70,8 +70,8 @@ const requestHandler = async (req: IncomingMessage, res: ServerResponse, request
res.end(responseBody)
}

const getHandler = function (handlers, url) {
const handler = handlers.find(({ path }) => url === path || url.startsWith(`${path}?`))
const getHandler = function (handlers: Handler[], url?: string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Types taken from usage on line 48 in this file

@mrstork mrstork marked this pull request as ready for review June 24, 2025 14:36
@mrstork mrstork requested a review from a team as a code owner June 24, 2025 14:36
@@ -91,7 +90,13 @@ const fetchPluginsList = async function ({
pluginsListUrl: string
}): Promise<PluginListEntry[]> {
try {
const { body } = await got(pluginsListUrl, { responseType: 'json', timeout: { request: PLUGINS_LIST_TIMEOUT } })
const response = await fetch(pluginsListUrl, { signal: AbortSignal.timeout(PLUGINS_LIST_TIMEOUT) })
Copy link
Contributor

Choose a reason for hiding this comment

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

got's responseType: 'json' also sets accept header to application/json ( https://github.com/sindresorhus/got/blob/a359bd385129d2adbc765b52dfbbadac5f54a825/source/core/index.ts#L636-L638 ) so for full 1 to 1 migration that could be added, tho doesn't seem like needed so this can be skipped

pieh
pieh previously approved these changes Jun 25, 2025
Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@mrstork mrstork enabled auto-merge (squash) June 25, 2025 13:37
@mrstork mrstork merged commit fed9e58 into main Jun 25, 2025
59 of 61 checks passed
@mrstork mrstork deleted the remove-got-dependency branch June 25, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants