nujan-ide icon indicating copy to clipboard operation
nujan-ide copied to clipboard

Display Tact compilation errors

Open novusnota opened this issue 1 year ago • 10 comments

Observed behaviour

Upon compilation error, user sees a cryptic "Error while building" message in the log output. And that's it, no details.

Expected behavior or possible solutions

Tact compiler provides details on compilation errors and it would be nice to see them in the log output even if the stack trace is truncated.

novusnota avatar Mar 28 '24 14:03 novusnota

The Tact compiler does not throw an errors in some cases; instead, it logs them to the console, as detailed in issue https://github.com/tact-lang/tact/issues/262. As a temporary workaround, I have implemented a method to capture console.error outputs and display them in the Nujan log.

Please notify me if there are any issues with errors not being logged properly.

rahulyadav-57 avatar Apr 19 '24 14:04 rahulyadav-57

@rahulyadav-57 I think this shall be re-opened, as dump() and emit() are not logged anymore after updating to Tact 1.3.0. Probably, we need to revert the temporary workaround you made before

novusnota avatar May 08 '24 10:05 novusnota

Hi @novusnota, I tested it and it works for me; could you help me to reproduce it?

rahulyadav-57 avatar May 09 '24 10:05 rahulyadav-57

Sure @rahulyadav-57, it works in init() and receive(), but doesn't work in (off-chain) getter functions get fun X()

novusnota avatar May 09 '24 12:05 novusnota

@novusnota Instead of intercepting the console which I did previously, which captures everything globally, I propose an alternative solution. We could replace the logger.js file after npm install in Nujan at node_modules/@tact-lang/compiler/dist/ with a custom logger that can dispatch events which can be capture by Nujan logger. This approach might provide more targeted and manageable event handling.

Something like

const disptachEvent = (type, args) => {
    const tactEvent = new CustomEvent("tactLogger", {
        detail: { data: args, type},
    });
    document.dispatchEvent(tactEvent);
    console[type](args);
}


exports.consoleLogger = {
    log: (message) => disptachEvent('log', message),
    error: (message) => disptachEvent('log', message),
};

What are your thoughts @anton-trunov on this?

rahulyadav-57 avatar May 10 '24 06:05 rahulyadav-57

@rahulyadav-57 I think we should fix it in Tact itself

anton-trunov avatar May 10 '24 07:05 anton-trunov

In general I would strongly discourage patching things up. Please don't shy away from fixing things in the compiler or any other tool, i.e. where it's relevant

anton-trunov avatar May 10 '24 07:05 anton-trunov

I agree with you. But for the current or older version of Tact, how should we proceed?

rahulyadav-57 avatar May 10 '24 07:05 rahulyadav-57

We can fix the current version of Tact, release it as v1.3.1 and require it should be the minimal Tact version for Nujan

anton-trunov avatar May 10 '24 07:05 anton-trunov

Yes, that solution would resolve the issue. I'll make the changes and raise a PR. However, in Nujan, we plan to support multiple versions of Tact, including older versions as well.

rahulyadav-57 avatar May 10 '24 07:05 rahulyadav-57