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

[fs-watch] function watch() callback interface WatchEvent Type mismatch. #2221

Closed
cheeselemon opened this issue Dec 17, 2024 · 3 comments
Closed
Labels
bug Something isn't working plugin: fs Includes former "fs-extra" and "fs-watch" plugins

Comments

@cheeselemon
Copy link

cheeselemon commented Dec 17, 2024

The Problem:

The docs state that the watch() function of plugin-fs as follows:

function watch(
   paths,
   cb,
options?): Promise<UnwatchFn>

and the cb is a function defined as: (event: WatchEvent) => void

the interface WatchEvent is declared as follows:

interface WatchEvent {
  type: WatchEventKind
  paths: string[]
  attrs: unknown
}

And checking out interface WatchEventKind:

type: WatchEventKind

However, upon implementing the watch() callback function, I found out that the actual data didn't contain type instead it had kind.

ie. the interface states that type : WatchEventKind, but the data was actually kind: WatchEventKind

Actual callback data sample:

{kind: {modify: {kind: "data", mode: "content"}}, paths: [".../some_path/..."], attrs: {}}

And upon checking out the watcher.rs native rust code, I can see that it's also declared as kind

Am I missing something?

How to fix?

As a workaround, I've declared a custom interface for this process in my own source code.

I think it'd be best if the type declaration was fixed on javascript.

Additional Info & Environment

my Cargo.toml:

[dependencies]
...
tauri-plugin-fs = { version = "2.0.0", features = ["watch"] }
...

Using verion 2.2.0 for tauri-plugin-fs didn't fix.

Operating system & App Platform : MacOS Silicon

@Legend-Master Legend-Master added bug Something isn't working plugin: fs Includes former "fs-extra" and "fs-watch" plugins labels Dec 17, 2024
@Legend-Master
Copy link
Contributor

Seems like notify changed the serialization in notify-rs/notify#558 and we thought with serialization-compat-6 feature introduced in notify-rs/notify#568, it would be the same as before but looks like there's a bug so... Will take a look and see if I could open a fix there

@dfaust
Copy link
Contributor

dfaust commented Dec 17, 2024

I just published notify-types-1.0.1, so a cargo update should fix the issue.
Thanks again for the PR @Legend-Master.

@cheeselemon
Copy link
Author

Awesome, thanks a lot ! 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin: fs Includes former "fs-extra" and "fs-watch" plugins
Projects
None yet
Development

No branches or pull requests

4 participants