Skip to content

Task 16: Node Script Hides the Real Rust Panic Message on CLI Failure #312

Description

@grantfox-oss

When the grat Rust binary encounters a fatal internal error, such as an out of bounds memory panic, an unsupported XDR version, or a corrupted cryptographic signature, it exits the process with a non zero status code and dumps the internal error trace directly to the standard error (stderr) stream. Unfortunately, Node.js treats any non zero exit code as a generic ChildProcessError. By default, Node.js swallows the actual contextual error message emitted by Rust, leaving developers blind to the true root cause of the failure. This results in countless hours wasted debugging the JavaScript layer when the actual fault lies deep within the Rust execution engine.

Issues/what to fix

The asynchronous try/catch block surrounding the promisified execFile invocation must be dramatically enhanced to intercept the raw ChildProcessError object. The script must inspect the error object, explicitly extracting the error.code (the system exit code) and parsing the error.stderr buffer string. Once extracted, the script must synthesize this information and construct a custom JavaScript GratCliError class that seamlessly surfaces the underlying Rust panic message, the execution duration, and the specific exit code. This custom error must then be elegantly printed to the console using warning colors, completely suppressing the unhelpful Node.js generic stack trace.

Files location

examples/cli automation/cli integration/index.js

Expected result

In the event of a Rust binary failure, the Node.js console will act as a transparent window, printing the exact Rust panic or syntax error message. This transforms cross language debugging from a frustrating black box experience into a highly deterministic, fully transparent process.

Contributor telegram group

https://t.me/+sII7WPhll2liMGNk

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions