Skip to content

I see only a part of Debug.print messages for an one-way function #4041

Open
@vporton

Description

@vporton

Code like this does not print the value of the exception:

    public shared({caller}) func installPackageWrapper({ // TODO: Rename.
        whatToInstall: {
            #package;
            #simplyModules : [(Text, Common.SharedModule)];
        };
        repo: Common.RepositoryPartitionRO;
        pmPrincipal: Principal;
        packageName: Common.PackageName;
        version: Common.Version;
        installationId: Common.InstallationId;
        preinstalledModules: [(Text, Principal)];
        user: Principal;
    }): () {
        try {
            Debug.print("R1");
            onlyOwner(caller, "installPackageWrapper");
            ...
            Debug.print("R2: " # debug_show(Iter.toArray(preinstalled2.entries())));
            // Throws an exception:
            let ?backend = preinstalled2.get("backend") else { // FIXME
                Debug.trap("error 1");
            };
            ...
            Debug.print("R3");
            ...
        };
        catch (e) {
            Debug.print("ONE installPackageWrapper");
            Debug.print("installPackageWrapper: " # Error.message(e));
        };
    };

Actually, it prints:

2024-12-15 16:53:47.297878369 UTC: [Canister 6cvy2-omaaa-aaaaa-qackq-cai] R1
2024-12-15 16:53:47.297878369 UTC: [Canister 6cvy2-omaaa-aaaaa-qackq-cai] R2: []
$ dfx --version
dfx 0.24.0

Apparently, we don't see messages printed by an one-way function produces by it right before its exit. This severely complicates debugging.

Sadly, to give you a repeatable bug code, I would need to disclose my closed source. Even if I did disclose it, to reprise the bug, need to follow a relatively complex GUI procedure, so it is not repeatable automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThis ticket needs investigation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions