refactor: downloadSmallObject no longer uses ErrTuples
This commit is contained in:
parent
3c8eb1b081
commit
75c6c30284
|
@ -10,18 +10,12 @@ import {
|
||||||
objAsString,
|
objAsString,
|
||||||
sha512,
|
sha512,
|
||||||
} from "@lumeweb/libkernel";
|
} from "@lumeweb/libkernel";
|
||||||
import {
|
import { deriveChildKey, downloadSmallObject } from "@lumeweb/libweb";
|
||||||
CID,
|
import { CID, CID_TYPES } from "@lumeweb/libs5";
|
||||||
decodeCid,
|
|
||||||
deriveChildKey,
|
|
||||||
downloadSmallObject,
|
|
||||||
verifyCid,
|
|
||||||
} from "@lumeweb/libweb";
|
|
||||||
import { CID_TYPES, CID_HASH_TYPES } from "@lumeweb/libs5";
|
|
||||||
import type { moduleQuery, presentKeyData } from "@lumeweb/libkernel/module";
|
import type { moduleQuery, presentKeyData } from "@lumeweb/libkernel/module";
|
||||||
|
import { defer } from "@lumeweb/libkernel/module";
|
||||||
import { readableStreamToUint8Array } from "binconv";
|
import { readableStreamToUint8Array } from "binconv";
|
||||||
import { getSavedRegistryEntry } from "./registry.js";
|
import { getSavedRegistryEntry } from "./registry.js";
|
||||||
import { defer } from "@lumeweb/libkernel/module";
|
|
||||||
import { networkReady, resolveModuleRegistryEntry } from "./coreModules.js";
|
import { networkReady, resolveModuleRegistryEntry } from "./coreModules.js";
|
||||||
|
|
||||||
// WorkerLaunchFn is the type signature of the function that launches the
|
// WorkerLaunchFn is the type signature of the function that launches the
|
||||||
|
@ -537,10 +531,12 @@ async function handleModuleCall(
|
||||||
modulesLoading[moduleDomain] = new Promise(async (resolve) => {
|
modulesLoading[moduleDomain] = new Promise(async (resolve) => {
|
||||||
// TODO: Check localStorage for the module.
|
// TODO: Check localStorage for the module.
|
||||||
|
|
||||||
// Download the code for the worker.
|
let moduleData;
|
||||||
const [moduleData, errDS] = await downloadSmallObject(finalModule);
|
|
||||||
if (errDS !== null) {
|
try {
|
||||||
const err = addContextToErr(errDS, "unable to load module");
|
moduleData = await downloadSmallObject(finalModule);
|
||||||
|
} catch (e) {
|
||||||
|
const err = addContextToErr(e, "unable to load module");
|
||||||
respondErr(event, messagePortal, isWorker, isInternal, err);
|
respondErr(event, messagePortal, isWorker, isInternal, err);
|
||||||
resolve(err);
|
resolve(err);
|
||||||
delete modulesLoading[moduleDomain];
|
delete modulesLoading[moduleDomain];
|
||||||
|
|
Loading…
Reference in New Issue