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

chore: remove got dependency #6497

Draft
wants to merge 28 commits into
base: unstable
Choose a base branch
from

Conversation

HiroyukiNaito
Copy link
Contributor

@HiroyukiNaito HiroyukiNaito commented Feb 28, 2024

Motivation

For the solution of #6488

Description

Changed all codes which use got to fetch module.
Closes # #6488

Steps to test or reproduce

yarn build
yarn test:unit

@HiroyukiNaito HiroyukiNaito requested a review from a team as a code owner February 28, 2024 12:38
@CLAassistant
Copy link

CLAassistant commented Feb 28, 2024

CLA assistant check
All committers have signed the CLA.

@HiroyukiNaito HiroyukiNaito changed the title Remove got dependency #6866 fix: Remove got dependency #6866 Feb 28, 2024
@HiroyukiNaito HiroyukiNaito changed the title fix: Remove got dependency #6866 fix: remove got dependency #6866 Feb 28, 2024
Copy link
Member

@jeluard jeluard left a comment

Choose a reason for hiding this comment

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

I don't see any changes to yarn.lock ?
The correct way to remove a dependency is to use the yarn remove command.

packages/cli/src/util/file.ts Outdated Show resolved Hide resolved
packages/cli/src/util/file.ts Outdated Show resolved Hide resolved
packages/state-transition/test/utils/testFileCache.ts Outdated Show resolved Hide resolved
packages/cli/src/util/file.ts Outdated Show resolved Hide resolved
packages/cli/src/util/file.ts Show resolved Hide resolved
packages/cli/src/networks/index.ts Outdated Show resolved Hide resolved
@nflaig
Copy link
Member

nflaig commented Feb 28, 2024

The correct way to remove a dependency is to use the yarn remove command.

@jeluard is there a difference between that and just removing it from package.json + running yarn install afterwards?

@jeluard
Copy link
Member

jeluard commented Feb 28, 2024

The correct way to remove a dependency is to use the yarn remove command.

@jeluard is there a difference between that and just removing it from package.json + running yarn install afterwards?

Probably not, somehow it feels safer to use yarn remove :)

HiroyukiNaito and others added 3 commits February 29, 2024 16:39
Co-authored-by: Julien <jeluard@users.noreply.github.com>
Co-authored-by: Julien <jeluard@users.noreply.github.com>
@HiroyukiNaito
Copy link
Contributor Author

The correct way to remove a dependency is to use the yarn remove command.

@jeluard is there a difference between that and just removing it from package.json + running yarn install afterwards?

Probably not, somehow it feels safer to use yarn remove :)

Sorry, should delete by yarn remove

@HiroyukiNaito HiroyukiNaito changed the title fix: remove got dependency #6866 chore: remove got dependency Feb 29, 2024
packages/cli/src/util/file.ts Outdated Show resolved Hide resolved
packages/cli/src/networks/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

Please make sure to verify locally that your changes at least build and there are no lint issues

At a minimum run

  • yarn build (or yarn check-types)
  • and yarn lint

@HiroyukiNaito
Copy link
Contributor Author

HiroyukiNaito commented Mar 1, 2024

Remaining task

  • Importing @lodestar/api for wrapedFetch function
  • Delete following codes
 if (err instanceof FetchError && err.code !== "ECONNREFUSED") {
            return {ok: true};
          }

4XX-5XX Error

Error: Error fetching bootnodes file: Status Code 404 (Not Found)
    at fetchBootnodes (file:///home/hnaito/lodestar/packages/cli/src/networks/index.ts:116:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at getNetworkBootnodes (file:///home/hnaito/lodestar/packages/cli/src/networks/index.ts:128:24)
    at beaconHandlerInit (file:///home/hnaito/lodestar/packages/cli/src/cmds/beacon/handler.ts:179:35)

Other error

Error fetching latest bootnodes: FetchError: Request to https://example-example-example.com/notfound failed, reason: getaddrinfo ENOTFOUND example-example-example.com
    at wrappedFetch (file:///home/hnaito/lodestar/packages/api/src/utils/client/fetch.ts:12:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at fetchBootnodes (file:///home/hnaito/lodestar/packages/cli/src/networks/index.ts:114:15)
    at getNetworkBootnodes (file:///home/hnaito/lodestar/packages/cli/src/networks/index.ts:128:24)
    at beaconHandlerInit (file:///home/hnaito/lodestar/packages/cli/src/cmds/beacon/handler.ts:179:35)
    at Object.beaconHandler [as handler] (file:///home/hnaito/lodestar/packages/cli/src/cmds/beacon/handler.ts:36:84)

@nflaig So far, pointed codes are corrected. However, you mentioned the nested Error still Nesting by FetchError.
https://github.com/ChainSafe/lodestar/pull/6497/files#diff-e138e8a415f1771c2089d8cf11a0ec52cb3c345e163e9b7573fc0284c342b4a1R130

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeluard I coded in network.ts as a utility function by wrapedFetch.

Copy link

codecov bot commented Mar 2, 2024

Codecov Report

Merging #6497 (e90a890) into unstable (6675739) will decrease coverage by 0.01%.
Report is 4 commits behind head on unstable.
The diff coverage is 22.22%.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #6497      +/-   ##
============================================
- Coverage     61.72%   61.71%   -0.01%     
============================================
  Files           555      555              
  Lines         58204    58217      +13     
  Branches       1843     1844       +1     
============================================
+ Hits          35926    35931       +5     
- Misses        22239    22247       +8     
  Partials         39       39              

@@ -102,13 +101,20 @@ export function getGenesisFileUrl(network: NetworkName): string | null {
* Fetches the latest list of bootnodes for a network
* Bootnodes file is expected to contain bootnode ENR's concatenated by newlines
*/
export async function fetchBootnodes(network: NetworkName): Promise<string[]> {

class FetchBootFileError extends Error {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I move the CustomError to the file?

export class LodestarError<T extends {code: string}> extends Error {

@@ -121,8 +127,13 @@ export async function getNetworkBootnodes(network: NetworkName): Promise<string[
const bootEnrs = await fetchBootnodes(network);
bootnodes.push(...bootEnrs);
} catch (e) {
// eslint-disable-next-line no-console
console.error(`Error fetching latest bootnodes: ${(e as Error).stack}`);
if (e instanceof FetchBootFileError) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I added the logic, the nested Error mesage resolved.

Suggested change
if (e instanceof FetchBootFileError) {
if (e instanceof FetchBootFileError) {
// eslint-disable-next-line no-console
console.error(`${(e as Error).stack}`);
}
if (e instanceof FetchError) {
console.error(`${(e as Error).stack}`);
}

The message becomes

FetchError: Request to https://example-example-example.com/notfound failed, reason: getaddrinfo ENOTFOUND example-example-example.com
    at wrappedFetch (file:///home/hnaito/lodestar/packages/api/src/utils/client/fetch.ts:12:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at fetchBootnodes (file:///home/hnaito/lodestar/packages/cli/src/networks/index.ts:114:15)
    at getNetworkBootnodes (file:///home/hnaito/lodestar/packages/cli/src/networks/index.ts:128:24)
    at beaconHandlerInit (file:///home/hnaito/lodestar/packages/cli/src/cmds/beacon/handler.ts:179:35)
    at Object.beaconHandler [as handler] (file:///home/hnaito/lodestar/packages/cli/src/cmds/beacon/handler.ts:36:84)

@HiroyukiNaito HiroyukiNaito marked this pull request as draft March 11, 2024 09:05
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.

None yet

5 participants