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

stringifyJSHandle hides certain error details when run from command line #4736

Open
msporny opened this issue Jun 12, 2024 · 3 comments · May be fixed by #4781
Open

stringifyJSHandle hides certain error details when run from command line #4736

msporny opened this issue Jun 12, 2024 · 3 comments · May be fixed by #4781
Labels

Comments

@msporny
Copy link

msporny commented Jun 12, 2024

Description of problem

Bear with me, this one is difficult to explain. More recently (ReSpec v35.1.0 -- June 2024), when ReSpec is invoked via the command line, some ReSpec processing errors result in [ERROR] undefined being reported to the console. This causes Github Actions to fail without providing a useful error. When the same file is processed through a graphic Chromium session, depending on the complexity of the ReSpec document, sometimes a more detailed error is reported, and sometimes no error is reported at all.

URL to affected spec or repo:

https://github.com/speced/respec/blob/main/tools/respecDocWriter.js#L320

What happened (e.g., it crashed)?:

Given this basic ReSpec HTML document as input (only the citation for [[[PRIVACY-BY-DESIGN]]] matters, because processing it is what throws the error):

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>ReSpec citation bug v1.0</title>
    <script
      src="https://www.w3.org/Tools/respec/respec-w3c"
      class="remove"
      defer
    ></script>
    <script class="remove">
      // All config options at https://respec.org/docs/
      var respecConfig = {
        specStatus: "ED",
        editors: [{ name: "Your Name", url: "https://your-site.com" }],
        github: "some-org/mySpec",
        shortName: "respec-citation-bug",
        xref: "web-platform",
        group: "vc",
      };
    </script>
  </head>
  <body>
    <section id="abstract">
      <p>This is required.</p>
    </section>
    <section id="sotd">
      <p>This is required.</p>
    </section>
    <section class="informative">
      <h1>Demonstration of Bug</h1>
      <p>The bug appears when you cite [[[PRIVACY-BY-DESIGN]]].</p>
    </section>
    <section id="conformance">
      <p>
        This is required for specifications that contain normative material.
      </p>
    </section>
  </body>
</html>

Processing the document above leads to this error in a Chromium Version 121.0.6167.139 browser:

image

and this is what is reported when the same file is processed using the respec command line (via npx respec -s https://website.example/respec-bug.html -o index.html.built.html --verbose -t 60 -e):

image

and this is what it looks like in a Github Action failure:

image

I spent a bit of time and was able to track this down to the stringifyJSHandle call here:

https://github.com/speced/respec/blob/main/tools/respecDocWriter.js#L320

... which is dealing with a message that has this form:

{type, msgText, text, args} -> { "error", "JSHandle@error", "{}", ['{}'] }

... and that results in the [ERROR] undefined text being printed to the console when respec is invoked as a command line tool. The bug is triggered because the specref entry for [[[PRIVACY-BY-DESIGN]]] seems to be malformed (that's a separate problem I'll chase down on the specref repo). However, the browser console shows the error (sometimes), but the command line seems to swallow the error.

Expected behavior (e.g., it shouldn't crash):

The command line error should result in something that's more descriptive than [ERROR] undefined.

I did put in additional debug code and restructured the code a bit over an hour of trying to figure out where the issue was happening in ReSpec, and every now and then I could get a more detailed stack trace to appear, but it was sporadic (signalling some possible async issue) and I was trying out a few different debug approaches so I hesitate to guess at what is happening here.

Optional, steps to reproduce:

  1. Use the HTML file provided above.
  2. Run some variation of npx respec -s https://website.example/respec-bug.html -o index.html.built.html --verbose -t 60 -e on it.
  3. You should see [ERROR] undefined printed out to the console with a not very useful stack trace.

Breakpoint'ing or adding debugging statements around https://github.com/speced/respec/blob/main/tools/respecDocWriter.js#L320 might help.

/cc @iherman

@msporny msporny added the bug label Jun 12, 2024
@sidvishnoi
Copy link
Member

Thank you for the detailed error report!
I'll make sure ReSpec doesn't swallow details 😉
Hopefully this weekend..

@sidvishnoi
Copy link
Member

sidvishnoi commented Aug 25, 2024

This particular error was due to bad data being returned from Specref.
Will make ReSpec handle it correctly, not sure how though - should either try to accept it, or reject entirely. WDYT @marcoscaceres?
https://api.specref.org/bibrefs?refs=PRIVACY-BY-DESIGN returns a string, instead of an object.

CLI will show error details instead of undefined with #4781.

Another improvement to CLI and errors comes with #4782.

@msporny
Copy link
Author

msporny commented Aug 25, 2024

Wonderful, thank you @sidvishnoi ! :)

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

Successfully merging a pull request may close this issue.

2 participants