Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizer failing on marked NPM package #280

Open
technosophos opened this issue Aug 16, 2024 · 4 comments
Open

Wizer failing on marked NPM package #280

technosophos opened this issue Aug 16, 2024 · 4 comments

Comments

@technosophos
Copy link

I don't know if it is worth capturing errors like this, but..

The marked Markedown parser seems to cause a failure in Wizer or Componentize.js

Steps to reproduce:

  1. Create a new TS project
  2. npm i and then npm i marked
  3. Edit the code as shown below
  4. run spin build --up

Code:

import { ResponseBuilder } from "@fermyon/spin-sdk";
import { Marked } from "marked";

export async function handler(req: Request, res: ResponseBuilder) {
    let md = new Marked();
    res.send(await md.parse("Hello _world_"));
}

Output:

$ spin build --up                 
Building component markdowntest with `npm run build`

> [email protected] build
> npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/markdowntest.wasm

asset dist.js 95.6 KiB [emitted] [javascript module] (name: main)
orphan modules 109 KiB [orphan] 24 modules
./src/spin.ts + 3 modules 95.6 KiB [built] [code generated]
webpack 5.93.0 compiled successfully in 723 ms
Using user provided wit in: combined-wit
Exception while pre-initializing: (new SyntaxError("invalid class property name in regular expression", "dist.js", 939))

Error: the `componentize.wizer` function trapped

Caused by:
    0: error while executing at wasm backtrace:
           0: 0x787037 - <unknown>!<wasm function 12587>
           1: 0x7864f8 - <unknown>!<wasm function 12364>
           2: 0x4f073d - <unknown>!<wasm function 1724>
           3: 0x323ccd - <unknown>!<wasm function 517>
    1: Exited with i32 exit status 1
file:///Users/technosophos/Code/TypeScript/markdowntest/node_modules/@bytecodealliance/componentize-js/src/componentize.js:221
    throw new Error(err);
          ^

Error: Failed to initialize the compiled Wasm binary with Wizer:
Wizering failed to complete
    at componentize (file:///Users/technosophos/Code/TypeScript/markdowntest/node_modules/@bytecodealliance/componentize-js/src/componentize.js:221:11)
    at async file:///Users/technosophos/Code/TypeScript/markdowntest/node_modules/@fermyon/spin-sdk/bin/j2w.mjs:45:23

Node.js v22.6.0
Error: Build command for component markdowntest failed with status Exited(1)
@technosophos
Copy link
Author

Similar problem with micromark

@technosophos
Copy link
Author

But for those looking for a working Markdown processor in Spin, markdown-it works great.

@tschneidereit
Copy link
Contributor

I can reproduce this with a very simple reduced test case:

addEventListener('fetch', async (event) => {
    "sdf".match(/[\p{L}\p{N}]/u);
});

Not yet sure why this fails: line 2 in that test case works in Firefox's devtools shell and in a standalone SpiderMonkey shell. Will dig in more.

@tschneidereit
Copy link
Contributor

oooh, I'm pretty sure I know: StarlingMonkey doesn't currently include unicode support, because that's broken in SpiderMonkey's WASI port. Unfortunately there's little we can do about that until that problem is fixed :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants