Skip to content

pbjs will not display error messages in some cases #1816

@binsee

Description

@binsee

protobuf.js version: 7.1.2

The following proto files are defined here:

// 1.proto

syntax = "proto3";

package test;

import './11.proto';
import './12.proto';
// 11.proto

syntax = "proto3";

package test;

message TestMsg {
  int32 id = 1;
}
// 12.proto

syntax = "proto3";

package test;

message TestMsg {
  int32 id = 1;
  int32 id = 1;
}
  • run command
pbjs -t json -o 1.json 1.proto --sparse

The following error should be thrown in the correct case, but it is not actually displayed:

Error: duplicate name 'id' in Type TestMsg

After debugging, I think the cause of the problem may be here

protobuf.js/src/root.js

Lines 97 to 106 in d026849

function finish(err, root) {
/* istanbul ignore if */
if (!callback)
return;
var cb = callback;
callback = null;
if (sync)
throw err;
cb(err, root);
}

Errors should be shown, not eaten silently, and we should fix it.

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