You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying it with prebuild -r electron -t 13.0.1 leads to errors such as tree-sitter\src\node.cc(32,129): error C2661: 'v8::ArrayBuffer::New': no overloaded function takes 3 arguments tree-sitter\src\node.cc(36,42): error C3536: 'js_transfer_buffer': cannot be used before it is initialized tree-sitter\src\node.cc(36,69): error C2665: 'v8::Uint32Array::New': none of the 2 overloads could convert all the argument types
I'm aware of #83, and the problems described above happen after changing binding.gyp to following
Any update on this? @sergei-dyshel Could you please PR the fix to this repo?
I also need to use Tree-Sitter in a VSCode extension, and limiting users to vscode-1.56.x is not wise.
Any update on this? @sergei-dyshel Could you please PR the fix to this repo? I also need to use Tree-Sitter in a VSCode extension, and limiting users to vscode-1.56.x is not wise.
The WASM version is slower, a real native version like the purpose of this repo is always preferred.
The repository just needs more maintenance but unfortunately @maxbrunsfeld seems to not have enough time for it, which is a real shame for such great project.
Exactly, I chose this repo over the WASM version specifically because I've read it's slower; but then I read somewhere that this is no longer the case. However a native solution is always the best.
From @Symbolk's commit, it doesn't look much work to switch back and forth between WASM and native versions, so I guess
I'll continue using the WASM version for now and wait for this repo to get updated.
Thanks!
Any update on this? @sergei-dyshel Could you please PR the fix to this repo? I also need to use Tree-Sitter in a VSCode extension, and limiting users to vscode-1.56.x is not wise.
Can anyone give a hint about prospects for an official fix?
As a related comment it looks like #52 could help with this sort of issue in a more general way, but from the conversation there I can't tell if it is still progressing.
@sergei-dyshel Could you please PR the fix to this repo?
I also need to use Tree-Sitter in a VSCode extension, and limiting users to vscode-1.56.x is not wise.
I don't see any point in opening CR. Maintainer seems to not be checking this repo otherwise he would fix this long ago.
Meanwhile you can create a fixed branch in your own fork and use it as a dependency in package.json. For example I have:
@sergei-dyshel Could you please PR the fix to this repo?
I also need to use Tree-Sitter in a VSCode extension, and limiting users to vscode-1.56.x is not wise.
I don't see any point in opening CR. Maintainer seems to not be checking this repo otherwise he would fix this long ago. Meanwhile you can create a fixed branch in your own fork and use it as a dependency in package.json. For example I have:
referring to a missing symbol definition for v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>)
which should be there
Shouldn't v8 be linked automatically?
Happy new year guys @sergei-dyshel When I use your repo for my vscode extension, I can rebuild modules for electron 13
But at runtime, VSCode says there is a symbol lookup error concerning v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>) (undefined).
nm says it's not defined too, but I guess that's OK as it seems VSCode loads libraries at runtime (there are a lot of undefined symbols from v8 at this point). Also, note that nm does not know a candidate library to look for the symbol in:
nm -C ./node_modules/tree-sitter/build/Release/obj.target/tree_sitter_runtime_binding.node | grep ArrayBuffer::New
U v8::ArrayBuffer::NewBackingStore(void*, unsigned long, void (*)(void*, unsigned long, void*), void*)
U v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>)
ldd does not mention anything about libv8 or libnode.a:
I tried this and had a similar experience, but didn't pursue and switched to WASM, which seems to work fine. Since rust and WASM bindings were moved into tree-sitter/lib it is probable that these are the bindings that will get the most consistent support from the main developers. So I join @Symbolk and suggest switch to WASM. For me the two issues with the switch were getting emscripten to produce a compatible WASM (solution is use Docker), and that I didn't know much about asynchronous functions in typescript (it's not hard to learn).
Well it is all good with the WASM build but the real native build provides 5x better performance.
A quick benchmark with parsing a html file yields:
On MacBook Pro M1 MAX:
File Size 25KB:
Parser
Time
Native Tree Sitter
1.71 ms
WASM Tree Sitter
8.20 ms
Native DOM Parser
2.69 ms
Parse5
16.71 ms
File Size 200KB:
Parser
Time
Native Tree Sitter
13.27 ms
WASM Tree Sitter
46 ms
Native DOM Parser
9.38 ms
Parse5
51.41 ms
On Windows 10 Pro with AMD Ryzen 7 3800X 8 Core 3.90 GHz:
File Size 25KB:
Parser
Time
Native Tree Sitter
4.55 ms
WASM Tree Sitter
12.03 ms
Native DOM Parser
3.71 ms
Parse5
25.17 ms
File Size 200KB:
Parser
Time
Native Tree Sitter
30.18 ms
WASM Tree Sitter
64.26 ms
Native DOM Parser
15.32 ms
Parse5
77.87 ms
So as try can see the native tree Sitter is much faster and on smaller files even faster than the native DOMParser in from the browser.
So we would really like to have a native version of the node-tree-sitter as well, next to the WASM version
However without a good rewrite to support NAPI as started in #52
Even with the current patches from #95 the current version will only work till Electron 13.
Starting from Electron 14 all non context aware modules that are not NAPI compatible, cannot be loaded any more as stated in: electron/electron#18397
So please @maxbrunsfeld have an urgent look on this.
tree-sitter doesn't build alongside the latest version of VSCode there error i get is:
error User\workspace\vscode\node_modules\tree-sitter: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments:
Directory: User\workspace\vscode\node_modules\tree-sitter
Output:
User\workspace\vscode\node_modules\node-abi\index.js:36
throw new Error('Could not detect abi for version ' + target + ' and runtime ' + runtime + '. Updating "node-abi" might help solve this issue if it is a new release of ' + runtime)
^
Error: Could not detect abi for version 17.4.0 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron
at getAbi (User\workspace\vscode\node_modules\node-abi\index.js:36:9)
at module.exports (User\workspace\vscode\node_modules\prebuild-install\rc.js:52:57)
at Object.<anonymous> (User\workspace\vscode\node_modules\prebuild-install\bin.js:8:25)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
User\workspace\vscode\node_modules\tree-sitter>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.4 found at "User\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe"
gyp info find VS using VS2019 (16.11.32228.343) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn User\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe
gyp info spawn args [
gyp info spawn args 'user\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'user\\workspace\\vscode\\node_modules\\tree-sitter\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'user\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'user\\AppData\\Local\\node-gyp\\Cache\\17.4.0\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=user\\AppData\\Local\\node-gyp\\Cache\\17.4.0',
gyp info spawn args '-Dnode_gyp_dir=user\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=user\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\17.4.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=user\\workspace\\vscode\\node_modules\\tree-sitter',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'user\\workspace\\vscode\\node_modules\\tree-sitter\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
User\workspace\vscode\node_modules\tree-sitter\src\conversions.cc(32,118): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [User\workspace\vscode\node_modules\tree-sitter\build\tree_sitter_runtime_binding.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (User\AppData\Roaming\nvm\v16.14.0\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (node:events:520:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Windows_NT 10.0.22000gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd User\workspace\vscode\node_modules\tree-sitter
Oh, that it is actually good news; Thanks! I have switched to WASM builds since, and they work - I can't remember if this was the only error but if I find time, I'll probably go back and try the native version
Please let me know if you end up with a reasonably clean solution.
This blog post contains an interesting deep dive into a similar issue that the author encountered when moving to chromium 90.0.4415.0. It seems Electron 13 was the first version to use a version of chromium greater than or equal to that. Their ultimate suggestion is similar to @gpetrov's (use NAPI).
Activity
Symbolk commentedon Aug 12, 2021
Yeah, I also have this problem, which is really exhausting:

I am developing a VSCode extension that depends on this native module: https://github.com/Symbolk/somanyconflicts. Previously, I have managed to conquer this problem for Node 14.16.0, Electron 12.0.4, electron-rebuild 2.3.5,node-gyp 8.1.0. However, recently VSCode upgrades its Electron to 13.1.7 (https://www.npmjs.com/package/electron-releases), and my users reported that the extension cannot run so I have to rebuild it. Then the annoying error happens again, just like the previous one about
std::remove_cv_t.I have given up it, and looking for a WebAssembly solution.
sergei-dyshel commentedon Sep 3, 2021
ArrayBufferAPI changed in newer V8 version, I have a fix in sergei-dyshel@961870e.gpetrov commentedon Oct 28, 2021
@maxbrunsfeld - could you incorporate the fix?
FoamScience commentedon Dec 17, 2021
Any update on this?
@sergei-dyshel Could you please PR the fix to this repo?
I also need to use Tree-Sitter in a VSCode extension, and limiting users to vscode-1.56.x is not wise.
Symbolk commentedon Dec 18, 2021
Hi, I suggest to use WASM version, like what I have done: https://github.com/Symbolk/somanyconflicts
gpetrov commentedon Dec 18, 2021
The WASM version is slower, a real native version like the purpose of this repo is always preferred.
The repository just needs more maintenance but unfortunately @maxbrunsfeld seems to not have enough time for it, which is a real shame for such great project.
FoamScience commentedon Dec 18, 2021
Exactly, I chose this repo over the WASM version specifically because I've read it's slower; but then I read somewhere that this is no longer the case. However a native solution is always the best.
From @Symbolk's commit, it doesn't look much work to switch back and forth between WASM and native versions, so I guess
I'll continue using the WASM version for now and wait for this repo to get updated.
Thanks!
FoamScience commentedon Dec 18, 2021
So, I tried to use the WASM version myself; but LSP logs say:
Any idea on what that might mean?
dfgordon commentedon Dec 19, 2021
Can anyone give a hint about prospects for an official fix?
As a related comment it looks like #52 could help with this sort of issue in a more general way, but from the conversation there I can't tell if it is still progressing.
sergei-dyshel commentedon Dec 20, 2021
I don't see any point in opening CR. Maintainer seems to not be checking this repo otherwise he would fix this long ago.
Meanwhile you can create a fixed branch in your own fork and use it as a dependency in
package.json. For example I have:FoamScience commentedon Dec 20, 2021
dfgordon commentedon Dec 22, 2021
I was getting this also. The error went away after rebuilding the WASM using docker instead of
emsdk.FoamScience commentedon Dec 23, 2021
Even with this approach (which works) I still get a:
referring to a missing symbol definition for
v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>)which should be there
Shouldn't v8 be linked automatically?
FoamScience commentedon Jan 3, 2022
Happy new year guys
@sergei-dyshel When I use your repo for my vscode extension, I can rebuild modules for electron 13
But at runtime, VSCode says there is a symbol lookup error concerning
v8::ArrayBuffer::New(v8::Isolate*, std::shared_ptr<v8::BackingStore>)(undefined).nmsays it's not defined too, but I guess that's OK as it seems VSCode loads libraries at runtime (there are a lot of undefined symbols from v8 at this point). Also, note that nm does not know a candidate library to look for the symbol in:ldddoes not mention anything aboutlibv8orlibnode.a:Anyone has experienced this before? Any help is much appreciated as it's driving me crazy 😄
dfgordon commentedon Jan 7, 2022
I tried this and had a similar experience, but didn't pursue and switched to WASM, which seems to work fine. Since rust and WASM bindings were moved into
tree-sitter/libit is probable that these are the bindings that will get the most consistent support from the main developers. So I join @Symbolk and suggest switch to WASM. For me the two issues with the switch were getting emscripten to produce a compatible WASM (solution is use Docker), and that I didn't know much about asynchronous functions in typescript (it's not hard to learn).FoamScience commentedon Jan 7, 2022
Yes, exactly, plus I confirm there is no performance overhead when using the WASM version; at least for my parser.
gpetrov commentedon Jan 7, 2022
Well it is all good with the WASM build but the real native build provides 5x better performance.
A quick benchmark with parsing a html file yields:
On MacBook Pro M1 MAX:
File Size 25KB:
File Size 200KB:
On Windows 10 Pro with AMD Ryzen 7 3800X 8 Core 3.90 GHz:
File Size 25KB:
File Size 200KB:
So as try can see the native tree Sitter is much faster and on smaller files even faster than the native DOMParser in from the browser.
So we would really like to have a native version of the node-tree-sitter as well, next to the WASM version
However without a good rewrite to support NAPI as started in #52
Even with the current patches from #95 the current version will only work till Electron 13.
Starting from Electron 14 all non context aware modules that are not NAPI compatible, cannot be loaded any more as stated in: electron/electron#18397
So please @maxbrunsfeld have an urgent look on this.
jasonwilliams commentedon Apr 18, 2022
tree-sitter doesn't build alongside the latest version of VSCode there error i get is:
Sarrus1 commentedon Aug 11, 2022
Hi, any update on this?
jasonwilliams commentedon Oct 7, 2022
bencwallace commentedon Jan 8, 2023
@FoamScience
I think I've found the symbol for
Newin the electron (13.6.9) binary:The last of these seems to be what is needed. Unfortunately, it seems to be using the LLVM runtime.
I guess if you can run prebuild against libc++, it might solve this problem.
FoamScience commentedon Jan 8, 2023
Oh, that it is actually good news; Thanks! I have switched to WASM builds since, and they work - I can't remember if this was the only error but if I find time, I'll probably go back and try the native version
bencwallace commentedon Jan 8, 2023
Please let me know if you end up with a reasonably clean solution.
This blog post contains an interesting deep dive into a similar issue that the author encountered when moving to chromium 90.0.4415.0. It seems Electron 13 was the first version to use a version of chromium greater than or equal to that. Their ultimate suggestion is similar to @gpetrov's (use NAPI).
verhovsky commentedon Jun 22, 2023
verhovsky commentedon Jun 24, 2023
This should be fixed with node-tree-sitter v0.20.4. If someone could confirm or re-open the issue if it's still not fixed, that would be great.
segevfiner commentedon Jul 11, 2024
node-tree-sitter is now Node-API and should be compatible with Electron natively. This can be closed.