treebeardtech / whaler-ui

2 stars 0 forks source link

Unhandled Rejection (Error): no root #5

Open ievans opened 3 years ago

ievans commented 3 years ago

Hi! I just discovered this project and I really like it! I'm trying to use the UI directly to analyze a local disk, and I am wondering if you can help me debug something or if there is a bug in the code -- I'm not familiar enough with d3-hierarchy to quite understand the inner workings. When I run du on / and try to load the result, I get an exception through saying "no root."

$ du -k -a / > whaler-ui/public/du.txt
$ wc -l public/du.txt
10583358 public/du.txt
Unhandled Rejection (Error): no root
stratify
node_modules/d3-hierarchy/src/stratify.js:57
getHierarchy
src/lib.ts:14
  11 |   width: number,
  12 |   height: number
  13 | ) => HierarchyRectangularNode<FsNode> = (data, width, height) => {
> 14 |   const h = d3
  15 |     .stratify<FsNode>()
  16 |     .id((d) => d.id)
  17 |     .parentId((d) => d.id.substring(0, d.id.lastIndexOf('/')))(data)

I thought this might mean there was no / entry in du.txt but there is:

$ tail public/du.txt
...
6408628 /Volumes
85013501    /
alex-treebeard commented 3 years ago

hey @ievans sorry for the slow reply (not sure why I didn't see a notif for this).

A quirk of the front-end being hacked together is it appears it needs paths to NOT start with /

As you can see in the deployed version, it is run from the current directory

and if you run on a non-docker dir from the cli you can see (note: this may be what you are trying to achieve anyway?)

➜ whaler /
Running bash -c cd / && du -a -k

which will mean all paths are pre-pended with a single root .

So I would say change directory into / and then run without a location argument.

Please let me know if this fixes your problem!

ievans commented 3 years ago

hi @alex-treebeard -- thanks for the advice and response! I tried running cd / && du -a -k > $whaler_dir/public/du.txt but had the same issue. A little bit more digging and it seemed I could reproduce that I can also get that error when something like this occurs:

ok:

...
328038 /Volumes/SomeDrive
6408628 /Volumes
85013501    /

not ok:

...
328038 /Volumes/SomeDrive
85013501    /

basically it seems that if an intermediary path is missing, the "no root" exception occurs. I'm not sure how exactly to narrow it down, but du might not be guaranteed to produce a listing for every intermediary folder?

alex-treebeard commented 3 years ago

@ievans which platform are you on?

On both OS X and Ubuntu, if I run du without a location arg then all paths start in .

There are three problems with your second example on my end:

328038 /Volumes/SomeDrive
85013501    /
  1. The top line is space delimited, not tab-delimited, this is causing the tsv parsing to silently fail (presumably caused by your IDE when debugging this)
  2. The paths do not start with . -- no idea why you are getting this on your end, perhaps it is platform related?
  3. You are missing the Volumes line. If I fix the other problems, then i see: Uncaught (in promise) Error: missing: ./Volumes at stratify (stratify.js:46)

here is a du.txt which should trigger 3:

328038  ./Volumes/SomeDrive
85013501    .

the following is how I expect this to work properly:

328038  ./Volumes/SomeDrive
424242  ./Volumes
85013501    .

Note two things:

  1. The root path is . not /
  2. The sizes of all directories are irrelevant: d3 re-calculates them based on the leaf-nodes (file sizes) on page-load.
ievans commented 3 years ago

@alex-treebeard thanks for the detailed follow up, and sorry for my delayed reply. I'm on OSX 11.2.1, but I was a bit careless in my previous report: I tried to truncate the reproduction for brevity, and in doing so converted tabs to spaces. And also I also observe that all paths start with . if not specifying a directory--looks like I did my reproduction example specifying / explicitly, sorry!

Here's a direct copy-paste of the final couple lines of du.txt, generated via cd / && du -a -k | tee /tmp/du.txt

2683808 ./Volumes/BOOTCAMP/Windows/WinSxS
10426844    ./Volumes/BOOTCAMP/Windows
64086028    ./Volumes/BOOTCAMP
64086028    ./Volumes
0   ./tmp
0   ./cores
714699253   .

Even with the proper invocation so that we see . everywhere, I still get the no root exception.

If you run it on a live OSX system, are you able to successfully render the result? I have a lot of files, so I don't see an easy way to narrow down the issue.

$ wc -l public/du.txt
 9186392 public/du.txt

I think the next step would be to individually run du on every / subdirectory and recurse until I'm able to find the directory structure that causes the issue. Will do but it might take me a while, had to deprioritize this for now.