Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ The lock file is automatically generated and should be committed to version cont
```json
{
"lockVersion": 1,
"hemlock": "1.0.0",
"hemlock": "2.7.0",
"dependencies": {
"hemlang/sprout": {
"version": "2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hemlang/hpm",
"version": "1.2.0",
"version": "1.2.1",
"description": "Hemlock Package Manager - A package manager for the Hemlock programming language",
"author": "Hemlock Team",
"license": "MIT",
Expand Down
19 changes: 16 additions & 3 deletions src/github.hml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ export fn get_token() {
return null;
}

// Perform a GET, converting thrown network errors (connection failure,
// timeout) into a retryable status-0 response so retry loops can handle them
fn try_get(url: string, headers) {
try {
return get(url, headers);
} catch (e) {
return { status_code: 0, headers: [], body: "" };
}
}

// Make an authenticated GitHub API request with retry logic
fn github_request(url: string) {
let headers = [];
Expand All @@ -70,7 +80,7 @@ fn github_request(url: string) {
let backoff_s = INITIAL_BACKOFF_S;

while (retries <= MAX_RETRIES) {
let response = get(url, headers);
let response = try_get(url, headers);

if (response.status_code == 403) {
// Rate limit - retry with exponential backoff
Expand All @@ -95,6 +105,9 @@ fn github_request(url: string) {
backoff_s = backoff_s * 2;
continue;
}
if (response.status_code == 0) {
throw "GitHub API request failed (network error) after " + MAX_RETRIES + " retries";
}
throw "GitHub API error: HTTP " + response.status_code + " after " + MAX_RETRIES + " retries";
}

Expand Down Expand Up @@ -292,9 +305,9 @@ export fn repo_exists(owner: string, repo: string): bool {
let backoff_s = INITIAL_BACKOFF_S;

while (retries <= MAX_RETRIES) {
let response = get(url, headers);
let response = try_get(url, headers);

// Retry on rate limit or server errors
// Retry on rate limit, server errors, or network failures
if (response.status_code == 403 || response.status_code >= 500 || response.status_code == 0) {
if (retries < MAX_RETRIES) {
retries = retries + 1;
Expand Down
2 changes: 1 addition & 1 deletion src/lockfile.hml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let LOCK_VERSION = 1;
export fn create_empty() {
return {
lockVersion: LOCK_VERSION,
hemlock: "1.1.0",
hemlock: "2.7.0",
dependencies: {}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.hml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as installer from "./installer.hml";
import * as cache from "./cache.hml";

// Version info
let HPM_VERSION = "1.2.0";
let HPM_VERSION = "1.2.1";
github.init(HPM_VERSION);

// Exit codes
Expand Down
2 changes: 1 addition & 1 deletion test/test_lockfile.hml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export fn run() {
test("creates empty lockfile", fn() {
let lock = lockfile.create_empty();
assert_eq(lock.lockVersion, 1, "lockVersion");
assert_eq(lock.hemlock, "1.1.0", "hemlock");
assert_eq(lock.hemlock, "2.7.0", "hemlock");
assert_not_null(lock.dependencies, "dependencies");
});

Expand Down
Loading