Skip to content

install.js should support HTTPS_PROXY environment variable #347

@silverwind

Description

@silverwind

The esbuild module has below rudimentary fetch implementation that does not support fetching via HTTPS proxies which means the script will run for over 4 minutes waiting for the HTTPS request to timeout in environments without direct Internet connectivity.

I'd suggest switching to make-fetch-happen for this download which is a fetch-compatible module that npm itself uses and it has full proxy support.

function fetch(url2) {
  return new Promise((resolve, reject) => {
    https.get(url2, (res) => {
      if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
        return fetch(res.headers.location).then(resolve, reject);
      if (res.statusCode !== 200)
        return reject(new Error(`Server responded with ${res.statusCode}`));
      let chunks = [];
      res.on("data", (chunk) => chunks.push(chunk));
      res.on("end", () => resolve(Buffer.concat(chunks)));
    }).on("error", reject);
  });
}

Related: #319

I could probably send you a pull request but I could not find the source for this script in the repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions