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

intermittent error? #532

Open
Robert-Black opened this issue Sep 12, 2024 · 5 comments
Open

intermittent error? #532

Robert-Black opened this issue Sep 12, 2024 · 5 comments

Comments

@Robert-Black
Copy link

Robert-Black commented Sep 12, 2024

This is probably my bad coding, but I’m seeing an odd intermittent (but frequent enough to be annoying) error with Übersicht…

Multiple times a day, I get an error panel on my desktop, but if I refresh Übersicht it disappears only to reappear randomly-ish later, and then tends to stay around until I do a manual refresh.

At first I thought it might be the a problem with the shell command being run, having some sort of race condition, but I’ve verified that this still happens without the shell command, so that means there’s either a silly bug in my code, or my code is triggering something within Übersicht. My money’s on the former, so can anyone see where the problem is? The intermittent nature of it has me stumped ¯\_(ツ)_/¯

I almost forgot to add, I have the widget on multiple monitors, and sometimes the error only appears on one monitor, sometimes on both.

import { css } from "uebersicht";
import { run } from "uebersicht";

export const refreshFrequency = 601000;
export const command = "echo `cat '/Users/x/Library/Mobile Documents/com~apple~CloudDocs/file1.txt' '/Users/x/Library/Mobile Documents/com~apple~CloudDocs/Time Tracking/delimiter.txt' '/Users/x/Library/Mobile Documents/com~apple~CloudDocs/Time Tracking/file2.txt' '/Users/x/Library/Mobile Documents/com~apple~CloudDocs/Time Tracking/delimiter.txt' '/Users/x/Library/Mobile Documents/com~apple~CloudDocs/Time Tracking/file3.txt'  `";

export const className =`
  right: 1100px; top: 200px; width: 800px;  /* cut for length */ 
  h1 { /* cut for length */ }
  p { /* cut for length */ }
  p.main { /* cut for length */ }
  p.main span {  /* cut for length */ }
  p.extra { /* cut for length */ }
  .previousTimeTaken { /* cut for length */ }
  div { /* cut for length */ }
`

export const render = ({output}) => {
  var x = output.split('|');
  var previousTimeTaken = x[1].split('(');
  previousTimeTaken = "("+previousTimeTaken[1];
  
  var previousDescription = x[1].replace(previousTimeTaken,'');
  
  return (
	<div>
      <h1>stuff</h1>
      <p class='main'>{x[0]}<span> since&nbsp;{x[2]}</span></p>
      <p class='extra'>↖ {previousDescription} <span class='previousTimeTaken'>{previousTimeTaken}</span></p>
    </div>
  );
}

test

@felixhageloh
Copy link
Owner

felixhageloh commented Sep 18, 2024

your command probably encounters an error and output is undefined in that case. You can do two things:

Just make sure that output is defined

export const render = ({output}) => {
  if (output == null) return null;
  
  ...
}

or check whether there is an error and then display it. That way you might be able to figure out what the issue is:

export const render = ({output, error}) => {
  if (error != null) return <div>{JSON.stringify(error)}</div>;

  ....
}

@Robert-Black
Copy link
Author

Thanks! I'll give that a try and report back.

@Robert-Black
Copy link
Author

Curious. Here's the result…

Screenshot of BBEdit at 18 Sep 2024 at 6_15_22 pm

@felixhageloh
Copy link
Owner

your output must be empty in some cases, so maybe best to combine both approaches:

export const render = ({output, error}) => {
  if (error != null) return <div>{JSON.stringify(error)}</div>;
  if (!output) return null;
  ....
} 

@Robert-Black
Copy link
Author

That did the trick! Thank you.

BTW, switched to Sequoia today, and Übersicht hasn't skipped a beat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants