Closed pepicrft closed 11 months ago
I found what was causing the issue. AVA has an option, workerThreads
which is true
by default and leads to concurrent access to node-pty
causing it to abort. After I set it to false
things worked as expected.
@pepicrft I would reopen this. node-pty
should ideally throw a user-friendly error when running it in a worker thread.
cc @deepak1556
I tried vitest --no-threads
on this, but still get the same error:
bash exec: chat in /Users/linonetwo/Desktop/repo/langchain-alpaca/alpaca.cpp
FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place
1: 0x1036cbd55 node::Abort() (.cold.1) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
2: 0x102194259 node::Abort() [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
3: 0x10219434a node::OnFatalError(char const*, char const*) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
4: 0x1023113c2 v8::HandleScope::HandleScope(v8::Isolate*) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
5: 0x1020c0938 node::InternalCallbackScope::InternalCallbackScope(node::Environment*, v8::Local<v8::Object>, node::async_context const&, int) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
6: 0x1020c0df2 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
7: 0x1020c131c node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
8: 0x1075eb1b4 pty_after_waitpid(uv_async_s*) [/Users/linonetwo/Desktop/repo/langchain-alpaca/node_modules/.pnpm/node-pty@0.10.1/node_modules/node-pty/build/Release/pty.node]
9: 0x102c3fcab uv__async_io [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
10: 0x102c53a7b uv__io_poll [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
11: 0x102c40231 uv_run [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
12: 0x1020c1733 node::SpinEventLoop(node::Environment*) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
13: 0x1021d73d2 node::NodeMainInstance::Run() [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
14: 0x10215b08c node::LoadSnapshotDataAndRun(node::SnapshotData const**, node::InitializationResult const*) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
15: 0x10215b373 node::Start(int, char**) [/Users/linonetwo/.nvm/versions/node/v18.12.1/bin/node]
16: 0x7ff80322f310 start [/usr/lib/dyld]
I just tried to use node-pty
within a worker thread and got this error. Has anyone worked on a fix or a reduced test case for this? I can if not.
I looked around for some examples on how to do thread safe callbacks (which I am making an assumption is what we need to make this work in worker threads) based on the stack we are seeing. My guess is this section here needs to be updated to be something more like this example.
I am not typically a native module developer, but I am happy to try and work on this if someone can help make sure I am pointed in the right direction.
@pepicrft can you link to where it was fixed? Just for those interested in following along.
EDIT: I see you closed this once before, should I just make a new issue to keep open? Do you just clean out your open issues every once in a while or something?
Environment details
Issue description
As part of migrating Ink to be a pure ESM project, we came across an issue in
node-pty
that causes it to blow-up printing a V8 tacktrace:My guess is that it has something to do with the change in the module system used, but it's hard to tell because I don't know how to diagnose the issue. Thanks in advance.