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

tree-sitter undefined symbol: _ZN2v812BackingStore12EmptyDeleterEPvmS1_ #4188

Open
LowByteFox opened this issue Aug 17, 2023 · 10 comments
Open
Labels
bug Something isn't working napi Compatibility with the native layer of Node.js node.js Compatibility with Node.js APIs

Comments

@LowByteFox
Copy link
Contributor

LowByteFox commented Aug 17, 2023

What version of Bun is running?

0.7.4

What platform is your computer?

Linux 6.4.10-zen2-1-zen x86_64 unknown

What steps can reproduce the bug?

Create empty project, install both tree-sitter and tree-sitter-javascript with npm

type this into index.ts

const Parser = require('tree-sitter');
const JavaScript = require('tree-sitter-javascript');

const parser = new Parser();
parser.setLanguage(JavaScript);

const sourceCode = 'let x = 1; console.log(x);';
const tree = parser.parse(sourceCode);

console.log(tree.rootNode.toString());

run the file

What is the expected behavior?

When executed with node on index.cjs
(program (lexical_declaration (variable_declarator name: (identifier) value: (number))) (expression_statement (call_expression function: (member_expression object: (identifier) property: (p roperty_identifier)) arguments: (arguments (identifier)))))

What do you see instead?

1 | (function (id){"use strict";var cached=@requireMap.@get(id);const last5=id.substring(id.length-5);if(cached)return cached.exports;if(last5===".json"){var fs=globalThis[Symbol.for("_fs")
]||=@Bun.fs(),exports=JSON.parse(fs.readFileSync(id,"utf8"));return @requireMap.@set(id,@createCommonJSModule(id,exports,!0)),exports}else if(last5===".node"){const module=@createCommonJSMo
dule(id,{},!0);return process.dlopen(module,id),@requireMap.@set(id,module),module.exports}else if(last5===".toml"){var fs=globalThis[Symbol.for("_fs")]||=@Bun.fs(),exports=@Bun.TOML.parse(
fs.readFileSync(id,"utf8"));return @requireMap.@set(id,@createCommonJSModule(id,exports,!0)),exports}else{var exports=@requireESM(id);const cachedModule=@requireMap.@get(id);if(cachedModule
)return cachedModule.exports;return @requireMap.@set(id,@createCommonJSModule(id,exports,!0)),exports}})
                       ^
TypeError: /home/jani/tests/node_modules/tree-sitter/build/Release/tree_sitter_runtime_binding.node: undefined symbol: _ZN2v812BackingStore12EmptyDeleterEPvmS1_
      at internalRequire (:1:20)
      at /home/jani/tests/node_modules/tree-sitter/index.js:3:2
      at globalThis (/home/jani/tests/node_modules/tree-sitter/index.js:708:28)
      at require (:1:20)
      at /home/jani/tests/index.ts:1:6
      at globalThis (/home/jani/tests/index.ts:10:36)

Additional information

No response

@vjpr
Copy link
Contributor

vjpr commented Aug 22, 2023

Also in 0.8.0 canary.

Maybe related, seems it hasn't been published in a while: tree-sitter/tree-sitter-typescript#259

@LowByteFox
Copy link
Contributor Author

ping?

@sualehasif
Copy link

this is one of 2+ blocking reasons we cant use bun :(

@robobun robobun added the node.js Compatibility with Node.js APIs label Sep 9, 2023
@amaanq
Copy link

amaanq commented Sep 10, 2023

As a core tree-sitter member, I also get this error. I am excited to try out using bun with tree-sitter, but I'm not that experienced in nodejs/js/ts/bun as I am in rust/c/c++

It is not an issue in tree-sitter-typescript, that's just a grammar repo. node-tree-sitter is the repo of interest if using the node.js bindings, or tree-sitter core for the wasm bindings

Gonna tack on that iirc bun does not play super well with v8-specific stuff, that could be the issue, I can provide anything to help debug this anyways

@LowByteFox
Copy link
Contributor Author

Looking at the symbol, I can see v8
so it has to do something with it.

@sualehasif
Copy link

btw, i would love to help get this resolved. i know that in the short term, bun has no intention to implement the v8:: apis. maybe its worth rewriting this with napi.rs so that it can be used in bun?

@amaanq
Copy link

amaanq commented Sep 17, 2023

There is a plan to rewrite node-tree-sitter's binding using napi instead of nan, but that's a large-scale effort that has to be propagated upstream for downstream grammars will need to regenerate their bindings to leverage napi as well.

@sualehasif
Copy link

do you have an issue you can link to? wondering what the downstream grammar impacts are?

@amaanq
Copy link

amaanq commented Sep 17, 2023

relevant pr tree-sitter/node-tree-sitter#52

@nektro
Copy link
Member

nektro commented Oct 23, 2024

currently getting

error: Error
      at load (/Users/meghandenny/src/test/node_modules/node-gyp-build/node-gyp-build.js:22:10)
      at /Users/meghandenny/src/test/node_modules/tree-sitter-javascript/bindings/node/index.js:3:8
      at require (1:11)
      at /Users/meghandenny/src/test/index.js:2:7

Bun v1.1.30-debug+cb6ad49a3 (macOS arm64)

so im currently unable to reproduce the crash but if i edit the file to only have require("tree-sitter-javascript"); i get warning: Node-API function "napi_type_tag_object" is not implemented yet. so thats an actionable item

@nektro nektro added the napi Compatibility with the native layer of Node.js label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working napi Compatibility with the native layer of Node.js node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

6 participants