Skip to content

Trace errors in production for JavaScript executions sent by the server-side #188

@mcollovati

Description

@mcollovati

JavaScript's errors raised when executing code sent from the server-side (e.g. Page.executeJs()) cannot be traced in production because Flow client silently suppresses them.

vaadin/flow#2028
vaadin/flow#2963

To be able to trace errors from the server-sent JavaScript code in production mode, we may need to tweak the Flow client Console.reportStacktrace() method.

public static void reportStacktrace(Exception exception) {
    if (GWT.isScript()) {
        if (shouldLogToBrowserConsole) {
            doReportStacktrace(exception);
        }
    } else {
        exception.printStackTrace();
    }
}

where shouldLogToBrowserConsole = !ApplicationConfiguration.isProductionMode

It seems to me that instrumenting the GWT generated JavaScript code is not possible, or at least not easy to accomplish.

Something we can maybe do is to add a traceErrors flag in Flow client ApplicationConfiguration, propagate it to Console and change the above method to consider also this configuration.
Then, if we do not want the developers to be able to set the configuration on their own, we can try to add an instrumentation in Observability Kit that intercepts BootstrapHandler$ApplicationParameterBuilder.getApplicationParameters and adds the flag to the returned JsonObject.

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