Skip to content

Commit cc8215a

Browse files
committed
fix: Fixes bypass logic for remote Wasm
1 parent 526d73a commit cc8215a

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

.changeset/funny-coins-bow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@taskless/loader": patch
3+
---
4+
5+
Fixes the bypass logic for remote Wasm modules

src/lib/handler.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ export const createHandler = ({
3131
getModules: () => Promise<Map<string, Promise<Plugin>>>;
3232
}) =>
3333
http.all("https://*", async (info) => {
34+
// let a bypassed request through to any other handlers
35+
if (isBypassed(info.request)) {
36+
return undefined;
37+
}
38+
3439
// wait for loaded to unblock (means the shim library has loaded)
3540
// !ok means disable the library's functionality
3641
const ok = await loaded;
3742

38-
// let a bypassed request through to any other handlers
39-
if (!ok || isBypassed(info.request)) {
43+
if (!ok) {
4044
return undefined;
4145
}
4246

src/lib/taskless.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ export const taskless = (
215215
params: {
216216
version: "v1",
217217
},
218+
headers: {
219+
authorization: `Bearer ${secret}`,
220+
...bypass,
221+
},
218222
});
219223
} catch {}
220224
}
@@ -257,6 +261,7 @@ export const taskless = (
257261
headers: {
258262
authorization: `Bearer ${secret}`,
259263
"Content-Type": "application/json",
264+
...bypass,
260265
},
261266
body: JSON.stringify(networkPayload),
262267
},
@@ -318,6 +323,7 @@ export const taskless = (
318323
const response = await client["/{version}/config"].get({
319324
headers: {
320325
authorization: `Bearer ${secret}`,
326+
...bypass,
321327
},
322328
params: {
323329
version: "pre1",
@@ -368,7 +374,13 @@ export const taskless = (
368374
moduleSource.set(
369375
ident,
370376
(async () => {
371-
const data = await fetch(pack.url.source);
377+
logger.trace(`Fetching ${ident} from ${pack.url.source}`);
378+
const data = await fetch(pack.url.source, {
379+
headers: {
380+
...bypass,
381+
},
382+
});
383+
logger.trace(`Fetched ${ident} from ${pack.url.source}`);
372384
return data.arrayBuffer();
373385
})()
374386
);

0 commit comments

Comments
 (0)