-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make wasmbuild work in the browser again (#113)
- Loading branch information
Showing
9 changed files
with
162 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | ||
import { default as localDataDir } from "https://deno.land/x/[email protected]/data_local_dir/mod.ts"; | ||
import { fetchWithRetries } from "./fetch.js"; | ||
|
||
export async function cacheToLocalDir( | ||
url: URL, | ||
|
@@ -134,24 +135,3 @@ function windowsToFileUrl(path: string): URL { | |
} | ||
return url; | ||
} | ||
|
||
export async function fetchWithRetries(url: URL | string, maxRetries = 5) { | ||
let sleepMs = 250; | ||
let iterationCount = 0; | ||
while (true) { | ||
iterationCount++; | ||
try { | ||
const res = await fetch(url); | ||
if (res.ok || iterationCount > maxRetries) { | ||
return res; | ||
} | ||
} catch (err) { | ||
if (iterationCount > maxRetries) { | ||
throw err; | ||
} | ||
} | ||
console.warn(`Failed fetching. Retrying in ${sleepMs}ms...`); | ||
await new Promise((resolve) => setTimeout(resolve, sleepMs)); | ||
sleepMs = Math.min(sleepMs * 2, 10_000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | ||
|
||
/** @param {URL | string} url */ | ||
export async function fetchWithRetries(url, maxRetries = 5) { | ||
let sleepMs = 250; | ||
let iterationCount = 0; | ||
while (true) { | ||
iterationCount++; | ||
try { | ||
const res = await fetch(url); | ||
if (res.ok || iterationCount > maxRetries) { | ||
return res; | ||
} | ||
} catch (err) { | ||
if (iterationCount > maxRetries) { | ||
throw err; | ||
} | ||
} | ||
console.warn(`Failed fetching. Retrying in ${sleepMs}ms...`); | ||
await new Promise((resolve) => setTimeout(resolve, sleepMs)); | ||
sleepMs = Math.min(sleepMs * 2, 10_000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @param {number} a | ||
* @param {number} b | ||
*/ | ||
export function add(a, b) { | ||
return a + b; | ||
} |
Oops, something went wrong.