spiral-modules / php-grpc

:electric_plug: Fast and furious GRPC server for PHP applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error on file compilation with using imports from protobuf

vakafonic opened this issue · comments

commented

Proto file:

`
syntax = "proto3";

package blabla.bookshop.country;

import "vendor/blabla/common-client/source/common.proto";
import "google/protobuf/empty.proto";

option php_namespace = "Blabla\Bookshop\Client\Proto\Country";
option php_metadata_namespace = "Blabla\Bookshop\Client\Proto\Country\Meta";

service CountryService {
rpc GetCountryList (GetCountryListRequest) returns (GetCountryListResponse);
rpc AddCountry (Country) returns (google.protobuf.Empty);
rpc RemoveCountry (RemoveCountryRequest) returns (google.protobuf.Empty);
}

message GetCountryListRequest {
blabla.common.PaginationInput pagination = 1;
CountryFilter filter = 2;
}

message CountryFilter {
string name = 1;
string shortName = 2;
repeated string shopUUIDs = 3;
repeated string authorUUIDs = 4;
}

message GetCountryListResponse {
repeated Country countries = 1;
blabla.common.Pagination pagination = 2;
}

message Country {
string name = 2;
string shortName = 3;
}

message RemoveCountryRequest {
string countryName = 1;
}
`

Command

find ./source/ -name '*.proto' -print0 | xargs -0r
plugin/protoc-compiled-grpc-v1_30_0
--proto_path=./source
--proto_path=/usr/include \ # that is required for importing Protobuff extended types
--php_out=./compiled/php
--grpc_out=./compiled/php
--php-grpc_out=./compiled/php
--plugin=protoc-gen-grpc=./plugin/grpc_php_plugin-compiled-v1_30_0
--plugin=protoc-gen-php-grpc=./plugin/protoc-gen-php-grpc-v1_5_0
-I=.

Error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x62ea82]

goroutine 1 [running]:
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php.(*ns).importMessage(0xc0002acdb0, 0xc00007e000, 0xc0002b0a70)
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php/ns.go:69 +0x282
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php.newNamespace(0xc00007e000, 0xc0002c0000, 0xc0002a0d70, 0x85eb20)
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php/ns.go:42 +0x185
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php.body(0xc00007e000, 0xc0002c0000, 0xc0002a0d70, 0x40, 0x263)
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php/template.go:100 +0x5d
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php.generate(0xc00007e000, 0xc0002c0000, 0xc0002a0d70, 0x2)
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php/generate.go:50 +0xb6
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php.Generate(0xc00007e000, 0xc00011a000)
github.com/spiral/php-grpc/cmd/protoc-gen-php-grpc/php/generate.go:36 +0xc5
main.main()
command-line-arguments/main.go:41 +0x68
--php-grpc_out: protoc-gen-php-grpc: Plugin failed with status code 2.
make: *** [Makefile:33: compile-php] Error 123

Works without this plugin

@vakafonic Hey. RR1 and RR1 php-grpc will be deprecated soon (few weeks). If you'll see this issue in the v2.5.0 (roadrunner 2) and later, please, file the issue into the main roadrunner repository: https://github.com/spiral/roadrunner. Thanks.