hopsule 0.9.5 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install.js +7 -5
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -106,27 +106,29 @@ function downloadFile(url) {
106
106
  if (timer) clearTimeout(timer);
107
107
  };
108
108
 
109
- const follow = (url, redirects = 0) => {
109
+ const follow = (currentUrl, redirects = 0) => {
110
110
  if (redirects > 10) {
111
111
  cleanup();
112
112
  return reject(new Error("Too many redirects"));
113
113
  }
114
114
 
115
+ if (timer) clearTimeout(timer);
115
116
  timer = setTimeout(() => {
116
117
  reject(new Error(`Download timed out after ${DOWNLOAD_TIMEOUT_MS / 1000}s`));
117
118
  }, DOWNLOAD_TIMEOUT_MS);
118
119
 
119
120
  const req = https
120
- .get(url, { headers: { "User-Agent": "hopsule-npm-installer" } }, (res) => {
121
+ .get(currentUrl, { timeout: 30000, headers: { "User-Agent": "hopsule-npm-installer" } }, (res) => {
121
122
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
122
- clearTimeout(timer);
123
+ res.resume();
123
124
  return follow(res.headers.location, redirects + 1);
124
125
  }
125
126
 
126
127
  if (res.statusCode !== 200) {
128
+ res.resume();
127
129
  cleanup();
128
130
  return reject(
129
- new Error(`Download failed: HTTP ${res.statusCode} from ${url}`)
131
+ new Error(`Download failed: HTTP ${res.statusCode} from ${currentUrl}`)
130
132
  );
131
133
  }
132
134
 
@@ -190,7 +192,7 @@ function downloadFile(url) {
190
192
  req.on("timeout", () => {
191
193
  req.destroy();
192
194
  cleanup();
193
- reject(new Error("Connection timed out"));
195
+ reject(new Error(`Connection timed out (attempt to ${currentUrl.substring(0, 60)}...)`));
194
196
  });
195
197
  };
196
198
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hopsule",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "Decision-first, context-aware, portable memory system CLI",
5
5
  "keywords": [
6
6
  "cli",