Skip to content

Should show error message and not loop when there's an error #14

Open
@dreammaker

Description

@dreammaker

When the gnuplot program generates an error that isn't output instantly, GnuplotRB::Plot#plot loops forever and never displays the error message. This can come up in a number of ways and is particularly sinister because it hides the root cause of many different problems.

The code is reading the output of a separate process, so depending on execution order, you may not run into this problem. Sometimes just running it again works. But many times, it doesn't.

This may be somewhat related to #10. But I was trying to create a heatmap and ran into this. After hacking around it, I found that it's not related to a specific type of plot, but any error.

This is my workaround:

diff --git a/lib/gnuplotrb/plot.rb b/lib/gnuplotrb/plot.rb
index 1fb46f6..1809107 100644
--- a/lib/gnuplotrb/plot.rb
+++ b/lib/gnuplotrb/plot.rb
@@ -79,6 +79,7 @@ module GnuplotRB
       ds_string = @datasets.map { |dataset| dataset.to_s(terminal) }.join(' , ')
       full_command = @cmd + ds_string
       terminal.set(inner_opts).stream_puts(full_command).unset(inner_opts.keys)
+      sleep 1
       if inner_opts[:output]
         # guaranteed wait for plotting to finish
         terminal.close unless term

It's unsatisfactory because it sleeps unnecessarily, especially in non-error cases.

I think many people would appreciate having this fixed since showing the underlying error message is crucial, especially for new users (like me) who aren't familiar with what options they should be using. What ends up happening is people experiment with different options to see what happens. Unfortunately, as it is now, that often causes them to get stuck, not knowing how to proceed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions