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

Fix Deno check precluding esm.sh to start #327

Merged
merged 2 commits into from
May 19, 2022

Conversation

cristiano-belloni
Copy link
Contributor

This PR relates to #309
It essentially:

  • Makes the Deno check optional (so that esm.sh can still run in a restricted system where the Deno site is unreachable and only an internal NPM registry exists)
  • Uses Http.Get for it to honour env-defined http proxy URLs

server/nodejs.go Outdated
@@ -633,7 +633,7 @@ func toTypesPackageName(pkgName string) string {
}

func getDenoStdVersion() (version string, err error) {
resp, err := httpClient.Get("https://cdn.deno.land/std/meta/versions.json")
resp, err := http.Get("https://cdn.deno.land/std/meta/versions.json")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this because of the HTTP_PROXY issue you mentioned? If so, want to try to add Proxy field to the Transport config, to see if it works for you? It's essentially dropping in this line:

Proxy: http.ProxyFromEnvironment,

right below this line

ResponseHeaderTimeout: 60 * time.Second,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jimisaacs done, it seems to work. Thanks, go is not my usual language :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mine neither to be honest, I approved and am running the workflow, but I think @ije should give this change a look. I don't think that setting should have any overhead given that it's the default of go, but I wouldn't know at the scale @ije is operating this service.

FYI, the check failure looks unrelated to your change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ije added you here for this change (even though I realize i'll need to port it over to esmd regarding this PR #330)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ije added you here for this change (even though I realize i'll need to port it over to esmd regarding this PR #330)

@@ -143,7 +143,7 @@ func Serve(efs EmbedFS) {

denoStdVersion, err = getDenoStdVersion()
if err != nil {
log.Fatalf("getDenoStdVersion: %v", err)
log.Warnf("getDenoStdVersion: %v", err)
Copy link
Collaborator

@jimisaacs jimisaacs May 13, 2022

Choose a reason for hiding this comment

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

If you are not comfortable with my suggestion, please add a TODO / FIXME here to look at it later.

In build.go, there are places denoStdVersioin is used (lines 487, 706, 713).

There, it needs to check if denoStdVersioin is set, and if not build a string without it.

Example, this is what it would look like with it set: https://deno.land/std@0.139.0/archive/tar.ts
This is what it would look like without it set: https://deno.land/std/archive/tar.ts

The URL without it still works without the version with a redirect, so this is a valid change, but really only with the string update because that @ in the URL is invalid without a version there.

@@ -143,7 +143,7 @@ func Serve(efs EmbedFS) {

denoStdVersion, err = getDenoStdVersion()
if err != nil {
log.Fatalf("getDenoStdVersion: %v", err)
log.Warnf("getDenoStdVersion: %v", err)
}
log.Debugf("https://deno.land/std@%s found", denoStdVersion)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move this to an else, since it's not found ;)

@jimisaacs jimisaacs requested a review from ije May 16, 2022 15:49
Copy link
Member

@ije ije left a comment

Choose a reason for hiding this comment

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

LGTM

@ije ije merged commit 75cf9c8 into esm-dev:master May 19, 2022
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