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

Grammars built with Emscripten 3 don't load in browser: RuntimeError: abort(Assertion failed: undefined) #1560

Closed
verhovsky opened this issue Dec 29, 2021 · 3 comments · Fixed by #1913

Comments

@verhovsky
Copy link
Contributor

verhovsky commented Dec 29, 2021

I am trying to use tree-sitter in the browser (using Webpack) and when I load the grammar I built, I get this error

Uncaught (in promise) RuntimeError: abort(Assertion failed: undefined). Build with -s ASSERTIONS=1 for more info.
    at se (main.js:2)
    at N (main.js:2)
    at ye (main.js:2)
    at Le (main.js:2)
    at main.js:2
    at async main.js:2

It happens on this line

const Python = await Parser.Language.load('tree-sitter-python.wasm')

I can see that the wasm file gets requested and is successfully downloaded. This happens with other grammars, not just the Python grammar. I am able to load wasm files I built a couple months ago.

I am using Node 16 and emcc 3.0.2 installed with Homebrew on an M1 Macbook Air with macOS 12.1

$ node --version
v16.13.1
$ emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.0.2-git
$
$ which node
/opt/homebrew/opt/node@16/bin/node
$ which emcc 
/opt/homebrew/bin/emcc

I am building the grammar with

npx tree-sitter build-wasm node_modules/tree-sitter-python/

You can download a broken tree-sitter-bash.wasm file I built if you do

npm install curlconverter@4.0.0-alpha.8

In fact, the fastest way to reproduce this issue would be to

git clone git@github.com:curlconverter/curlconverter.github.io.git
cd curlconverter.github.io
git checkout c2d12aebf58c83f20a766edde46e875b5c976b6b

then in package.json change "curlconverter": "^4.0.0-alpha.7", to "curlconverter": "=4.0.0-alpha.8", before running npm install then running npm start and you should see the error in the browser's JS console. The grammar file shipped in the previous version (i.e. 4.0.0-alpha.7) should work though.

I also created a gist of a simpler project that I can reproduce this issue with: https://gist.github.com/verhovsky/a04c7256da13797e312acd0a8afd9023

@verhovsky verhovsky changed the title Built language grammars don't work in browser: RuntimeError: abort(Assertion failed: undefined) Grammars don't load in browser: RuntimeError: abort(Assertion failed: undefined) Dec 29, 2021
@mehmetoguzderin
Copy link
Contributor

(This comment is a temporary suggestion) Until a fix comes, I had a similar issue on a very similar environment, which I was able to solve using the Docker option as follows:

npx tree-sitter build-wasm --docker

@gpetrov
Copy link

gpetrov commented Jan 4, 2022

@maxbrunsfeld is there incompatibility with the latest Emscripten 3? the wasm binary is twice the size and bails out with the above assertion error.

Only forcing the compile through docker that uses Emscripten 2 helps...

@ahelwer
Copy link
Contributor

ahelwer commented Jan 4, 2022

I have to use EMCC 2.0.16. There's an old issue around here about this.

@verhovsky verhovsky changed the title Grammars don't load in browser: RuntimeError: abort(Assertion failed: undefined) Grammars built with Emscripten 3 don't load in browser: RuntimeError: abort(Assertion failed: undefined) Oct 22, 2022
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

Successfully merging a pull request may close this issue.

4 participants