-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: report missing import properly in loadSync #1960
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused, is callback
called elsewhere when using loadSync
, rather than line 105
?
if (sync) | ||
throw err; | ||
var cb = callback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style is internally consistent, so LGTM. But, it would be an improvement to use let
/ const
to protect us from weird scope issues.
Only in line 105, but |
This commit restores proto imports in the intended order, undoing the workaround in #108 due to protobufjs/protobuf.js#1954 now that the solution protobufjs/protobuf.js#1960 is implemented.
…,ListValue,Struct} (#131) The converter will now recognize a `format` specifier in certain schemas. Specifically, the following combinations are now recognized and result in a protobuf field whose type is the specified `format`: | Discovery `"type"` | Discovery `"format"` | |--------------------|-----------------------------| | `object` | `google.protobuf.Struct` | | `any` | `google.protobuf.Value` | | `array` | `google.protobuf.ListValue` | Note that, as was the case previously, other schemas with `"type" = "any"` and any other `format`, including none, are not accepted unless they are in an `error.details` field. (Googlers, see also cl/683528084.) Incidentally, this PR also restores proto imports in the intended order, undoing the workaround in #108 due to protobufjs/protobuf.js#1954 now that the solution protobufjs/protobuf.js#1960 is implemented.
Fixes #1954.
The
finish
function can be called in two modes, sync (when it throws an exception), or async (when it calls the callback). It makes sure the callback won't be called twice, but it makes one extra step and clean up the callback even it was called in sync mode. It causes problems such as in #1954 where instead of reporting "file not found" when parsing a proto, it jumps over that error and only reports the next error–or no error if the parsing happens to succeed without a bunch of imports being skipped as a result of the first exception.Let's avoid clearing the callback if we haven't used it yet.
The problem actually occurs when loading a proto file in sync mode (e.g. by running
root.loadSync(filename)
, which is whatpbjs
does), hence the PR title.