-
Notifications
You must be signed in to change notification settings - Fork 875
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
[bug] pipe crashing at deno runtime level ($200) #445
Comments
💎 $200 bounty • Screenpi.pe💎 $100 bounty • Screenpi.peSteps to solve:
Thank you for contributing to mediar-ai/screenpipe! Add a bounty • Share on socials
|
Hi @louis030195, I've taken a look at the deno/rust files, and I'm wondering why everything is set up on rust instead of letting the deno file run the parallelism. They have the Thread package, which probably should be more deterministic here. What do you think? |
@ologbonowiwi not familiar with deno, it's my first time using it, all i want ideally is:
atm what does not work:
the thread package seems interesting but i'd prefer people can just write normal js without problem and since most people these days use chatgpt to write code, it unlikely will use thread package (maybe im wrong) |
ideally we could have common js code -> run through through our deno code that uses the Thread package (and therefore can be parallelized without the hurdle of users doing it themselves) It’s my first time looking into an issue on the project so I’m not sure how it really works. any place where I could learn more about this part of the project? I need to gain more context on this but I have a good knowledge on js side so if I fill that gap I can handle this issue. /attempt #445
|
https://github.com/mediar-ai/screenpipe/blob/main/screenpipe-core/src/pipes.rs and the deno folder these are the only deno related code |
I heard that Deno has significant challenges making its runtime compatible with Node. I think there's a high chance we’re missing something Deno would natively do in case we use their CLI (or even starting their runtime in Rust, but not doing the back-and-forth to “mock” things like filesystem and fetch calls). Besides, we were not leveraging the event loop's power to do asynchronous processing (I/O, network calls, and so on). We’d be better off relying on the already-established tools of the JS runtime/ecosystem to do this heavy work and only having a specific layer inject some dependencies, such as custom pipes. Besides that, I think the way it is currently done has a high risk of unexpected behavior. If I’m using I'd recommend reframing our approach to rely most on the deno runtime and letting it do its magic on running the Js/ts scripts or creating explicitly different helpers. I mean, if we want to keep the filesystem requests on rust-land, per se, we could export I'm refraining from working on this because I think the way we're handling the scripts running is the root cause of our issues, and fixing it is more complex than I anticipated. |
I can't speak much to the above but I know that BorrowMutError is a consequence of using deno in tokio's multi-thread runtime. Deno needs to a in a current-thread runtime. I can make an /attempt #445, but the tricky part is going to be how to decide how to mix it in with the existing multi-threaded runtime. Options |
Yeah, I think we can have issues with the fact we are relying on Tokio threads to do async stuff such as filesystem calls. imo, we'd be better off handing this to deno (cause they already support it anyways) |
do you mean something like multiple deno projects in a multi-folder setup with a single cli command. here's how you can set it up:
here's a quick example structure:
in your import "./project1/main.ts";
import "./project2/main.ts";
import "./project3/main.ts";
console.log("all projects started"); then, you can run everything with a single command:
make sure to include any necessary permissions flags (like pro tip: if your projects are more complex and need to be initialized or have async operations, you could modify import { start as start1 } from "./project1/main.ts";
import { start as start2 } from "./project2/main.ts";
import { start as start3 } from "./project3/main.ts";
async function runAll() {
await Promise.all([
start1(),
start2(),
start3(),
]);
console.log("all projects started");
}
runAll(); eg. rust -> run deno cli that run some js code that import all pipes and run them or (AI suggestions): Based on the provided code for
To implement any of these approaches, you'd need to modify your existing code to work with Deno instead of the current runtime. This would involve adapting the module system, using Deno-specific APIs, and potentially restructuring parts of your application. |
That's precisely it. deno is mostly Node-compatible (source: Node APIs). So we can have imports + node native support + deno native support almost effortlessly. It can keep the Rust layer that instantiates the Deno runtime. We then run the |
i see
this will:
|
update: afraid not going to the deno cli path: https://github.com/mediar-ai/screenpipe/pull/462/files problem is that you can't write rust extensions easily this way and big next feature we're launching is the ability to control your computer in js eg await pipe.click({x: 200, y: 350})
await pipe.type("yo")
// or provide LLM tools like typing and mouse and give full autonomy to solve tasks on the computer ... right now i am going to investigate if i can import packages or use deno.json like when using cli using the current way |
other info: https://github.com/denoland/deno/blob/main/ext/webgpu/lib.rs seems to be possible to write rust extensions although not sure if need to be web assembly compatible (dont think the extensions i want to build can compile to wasm) |
ok here are my updated thoughts:
|
just looked at #462. it looks way cleaner now. did fetch and the other async stuff you used work properly? |
feat: use dependencies in pipes #445
now everything works except idk how to write rust extensions yet which is useful for low level / native stuff like keyboard control or mouse |
great to know! we can maybe close this issue then? And maybe create another issue for supporting rust? PS: I would appreciate a tip if my suggestions helped fix this. |
/tip $100 @ologbonowiwi thank you for the suggestions 🙏 |
@ologbonowiwi: You just got a $100 tip! We'll notify you once it is processed. |
🎉🎈 @ologbonowiwi has been awarded $100! 🎈🎊 |
denoland/deno_core#898
/bounty 200
definition of done:
The text was updated successfully, but these errors were encountered: