Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feedback
  • Loading branch information
pavelsavara committed Aug 9, 2022
commit f7c87a1107f648f0dde70da7c6da506e5b306a3e
7 changes: 5 additions & 2 deletions src/mono/wasm/runtime/crypto-worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { resolve_asset_path } from "./assets";
import { Module, runtimeHelpers } from "./imports";
import { mono_assert } from "./types";

Expand Down Expand Up @@ -107,7 +108,9 @@ export function init_crypto(): void {
console.debug("MONO_WASM: Initializing Crypto WebWorker");

const chan = LibraryChannel.create(1024); // 1024 is the buffer size in char units.
const worker = new Worker("dotnet-crypto-worker.js");
const asset = resolve_asset_path("js-module-crypto");
mono_assert(asset && asset.resolvedUrl, "Can't find js-module-crypto");
const worker = new Worker(asset.resolvedUrl);
mono_wasm_crypto = {
channel: chan,
worker: worker,
Expand All @@ -118,11 +121,11 @@ export function init_crypto(): void {
msg_buf: chan.get_msg_buffer(),
msg_char_len: chan.get_msg_len()
};
worker.postMessage(messageData);
worker.onerror = event => {
console.warn(`MONO_WASM: Error in Crypto WebWorker. Cryptography digest calls will fallback to managed implementation. Error: ${event.message}`);
mono_wasm_crypto = null;
};
worker.postMessage(messageData);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ export function bindings_init(): void {
*/
export async function mono_wasm_load_config(configFilePath?: string): Promise<void> {
if (configLoaded) {
return afterConfigLoaded.promise;
await afterConfigLoaded.promise;
return;
}
configLoaded = true;
if (!configFilePath) {
Expand Down