Skip to content

Failing to Initalize #13

@tance77

Description

@tance77

https://github.com/ije/md4w/blob/main/js/md4w.js#L240-L246

  if (wasmModule instanceof WebAssembly.Module) {
    const instance = new WebAssembly.Instance(wasmModule, { env });
    wasm = instance.exports;
  } else if (wasmModule.default && wasmModule.allocMem) {
    // unwasm specific
    wasmModule.default(env);
    wasm = wasmModule;
  } // There is no Else and it falls through and never initalizes

There should be am else here or maybe even a throw of some sort yes?

Both of these conditional statements fail to meet the conditions for some of our users. Which makes the const wasm; never be set.

This causes errors to be thrown later. Specifically here
https://github.com/ije/md4w/blob/main/js/md4w.js#L154-L160

  const ptrLen = wasm.render(
    allocMem(data),
    validateParseFlags(options.parseFlags),
    Math.max(estHtmlSize, 512),
    typeof highlighter === "function" ? 1 : 0,
    renderer,
  );
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions