prototool icon indicating copy to clipboard operation
prototool copied to clipboard

can we change the walktimeout ?

Open lynnzc opened this issue 7 years ago • 13 comments

Hi, I'm trying to lint my protobuf files, like prototool lint <dir>, sometimes I got errors like this:

walking the directory structure looking for proto files   
timed out after 3s and having seen 3000 files,   
are you sure you are operating in the right context?

https://github.com/uber/prototool/blob/dev/internal/file/proto_set_provider.go#L238-L240
https://github.com/uber/prototool/blob/dev/internal/settings/settings.go
seems we cannot change the timeout value via prototool.yaml
is there any way we can increase the default walk timeout of 3s?

lynnzc avatar Oct 24 '19 04:10 lynnzc

We could do that yeah.

smaye81 avatar Oct 25 '19 02:10 smaye81

Right now to me it feels like there is different issue underlying. I'm running prototool inside a 'node:10.16' docker container and trying to run lint as well – however it seems to always ignore the path given. It's printing the exact same error message @lynnzc is experiencing even if there are only 6 files inside the directory.

root@30b6c0a1ed38:/app# ls -l ./proto
total 56
-rw-r--r-- 1 root root  1855 Aug  8 14:59 xxx.proto
-rw-r--r-- 1 root root  3022 Aug 18 14:40 xxx.proto
-rw-r--r-- 1 root root  6549 Sep 19 10:09 xxx.proto
-rw-r--r-- 1 root root   470 Oct 23 19:55 xxx.proto
-rw-r--r-- 1 root root 25119 Sep 24 14:18 xxx.proto
-rw-r--r-- 1 root root  5315 Sep 19 10:09 xxx.proto
root@30b6c0a1ed38:/app# prototool lint ./proto
walking the directory structure looking for proto files timed out after 3s and having seen 2985 files, are you sure you are operating in the right context?

Same goes for navigating to the directory and then using prototool lint without parameter.

maxsommer avatar Oct 25 '19 08:10 maxsommer

I was able to fix this issue by adding all unnecessary folders to "exclude" list in prototool.yaml file. This is probably caused by combination of depth first search, slowness of docker filesystem and a ton of files generated by package managers. There should be an option to combine excludes with .gitignore file.

surajbarkale avatar Oct 30 '19 03:10 surajbarkale

@maxsommer @surajbarkale @smaye81 I started getting this error and I'm blocked... since I've had the same docker container for a while, what would have changed over time?? In addition, that's so weird to get a different report on the number of files searched...

I executed 5 times over a period of 1m... Why not removing this walk timeout? Anything that compiles would take time anyway... why limiting the time to search?

How can we set a higher value for this?

ERRO[2020-01-09T19:52:01-08:00] Can't generate the stubs: walking the directory structure 
looking for proto files timed out after 3s and having seen 631 files, are you sure you are
operating in the right context?

ERRO[2020-01-09T19:52:17-08:00] Can't generate the stubs: walking the directory structure 
looking for proto files timed out after 3s and having seen 596 files, are you sure you are 
operating in the right context?

ERRO[2020-01-09T19:52:30-08:00] Can't generate the stubs: walking the directory structure
 looking for proto files timed out after 3s and having seen 541 files, are you sure you are 
operating in the right context?

ERRO[2020-01-09T19:52:42-08:00] Can't generate the stubs: walking the directory structure
 looking for proto files timed out after 3s and having seen 483 files, are you sure you are 
operating in the right context?

ERRO[2020-01-09T19:52:55-08:00] Can't generate the stubs: walking the directory structure 
looking for proto files timed out after 3s and having seen 606 files, are you sure you are 
operating in the right context?

marcellodesales avatar Jan 10 '20 04:01 marcellodesales

  • Can we override this value? The current version users the default value
    • https://github.com/uber/prototool/blob/master/internal/file/proto_set_provider.go#L46
$ git --no-pager diff internal/file
diff --git a/internal/file/file.go b/internal/file/file.go
index 84244e1..e555293 100644
--- a/internal/file/file.go
+++ b/internal/file/file.go
@@ -30,7 +30,7 @@ import (
 )

 // DefaultWalkTimeout is the default walk timeout.
-const DefaultWalkTimeout time.Duration = 3 * time.Second
+const DefaultWalkTimeout time.Duration = 30 * time.Second

 var rootDirPath = filepath.Dir(string(filepath.Separator))
  • Tried to build locally, but even building from the master branch it breaks :(
~/dev/github.com/uber/prototool on  dev! ⌚ 21:15:28
$ make
git status --short > /var/folders/c8/p20lpvwn1kl7cyk7b282s3x1j2r82f/T/checknodiffgenerated_pre.XXXXX.2HYGkxSd
/Applications/Xcode.app/Contents/Developer/usr/bin/make generate
go install ./cmd/prototool
for file in internal/cmd/testdata/format/proto2/foo/foo_proto2.proto.golden internal/cmd/testdata/format/proto2/foo/bar/bar_proto2.proto.golden internal/cmd/testdata/format/proto3/foo/foo.proto.golden internal/cmd/testdata/format/proto3/foo/bar/bar.proto.golden internal/cmd/testdata/format-fix/foo.proto.golden internal/cmd/testdata/format-fix-v2/foo.proto.golden; do \
		rm -f ${file}; \
	done
for file in internal/cmd/testdata/format/proto2/foo/foo_proto2.proto internal/cmd/testdata/format/proto2/foo/bar/bar_proto2.proto internal/cmd/testdata/format/proto3/foo/foo.proto internal/cmd/testdata/format/proto3/foo/bar/bar.proto; do \
		prototool format ${file} > ${file}.golden || true; \
	done
for file in internal/cmd/testdata/format-fix/foo.proto internal/cmd/testdata/format-fix-v2/foo.proto; do \
		prototool format --fix ${file} > ${file}.golden || true; \
	done
go install github.com/golang/protobuf/protoc-gen-go
find example/gen -name '*.pb.go' | xargs rm -f
prototool all --fix example/proto/uber
go build ./example/gen/go/uber/foo/v1
go build ./example/gen/go/uber/bar/v1
go build -o .tmp/Darwin/x86_64/etc/excited ./example/cmd/excited/main.go
prototool lint etc/style/google
prototool lint etc/style/uber1
go install github.com/golang/protobuf/protoc-gen-go
find internal/cmd/testdata/grpc/gen -name '*.pb.go' | xargs rm -f
prototool generate internal/cmd/testdata/grpc
find internal/reflect/gen -name '*.pb.go' | xargs rm -f
prototool all --fix internal/reflect/proto
rm -f etc/config/example/prototool.yaml
prototool config init etc/config/example --uncomment
bazel run //:gazelle
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
DEBUG: Rule 'bazel_gazelle' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1555083723 -0400"
DEBUG: Call stack for the definition of repository 'bazel_gazelle' which is a git_repository (rule definition at /private/var/tmp/_bazel_mdesales/9c6d28a1af2ab7e529961613f842411b/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
 - /Users/mdesales/dev/github.com/uber/prototool/WORKSPACE:10:1
ERROR: /private/var/tmp/_bazel_mdesales/9c6d28a1af2ab7e529961613f842411b/external/io_bazel_rules_go/BUILD.bazel:62:1: in go_context_data rule @io_bazel_rules_go//:go_context_data:
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_mdesales/9c6d28a1af2ab7e529961613f842411b/external/io_bazel_rules_go/BUILD.bazel", line 62
		go_context_data(name = 'go_context_data')
	File "/private/var/tmp/_bazel_mdesales/9c6d28a1af2ab7e529961613f842411b/external/io_bazel_rules_go/go/private/context.bzl", line 396, in _go_context_data_impl
		cc_common.configure_features(<3 more arguments>)
Incompatible flag --incompatible_require_ctx_in_configure_features has been flipped, and the mandatory parameter 'ctx' of cc_common.configure_features is missing. Please add 'ctx' as a named parameter. See https://github.com/bazelbuild/bazel/issues/7793 for details.
ERROR: Analysis of target '//:gazelle' failed; build aborted: Analysis of target '@io_bazel_rules_go//:go_context_data' failed; build aborted
INFO: Elapsed time: 20.238s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (50 packages loaded, 6654 targets configured)
FAILED: Build did NOT complete successfully (50 packages loaded, 6654 targets configured)
    Fetching @org_golang_x_tools; Cloning 589c23e65e65055d47b9ad4a99723bc389136265 of https://go.googlesource.com/tools
make[1]: *** [bazelgen] Error 1
make: *** [checknodiffgenerated] Error 2

marcellodesales avatar Jan 10 '20 05:01 marcellodesales

I had downloaded cloned istio in the root dir of protos... resulting in the error above...

tree istio-1.4.2
177 directories, 639 files

After deleting this directory, I could run the prototool generate again...

marcellodesales avatar Jan 10 '20 07:01 marcellodesales

Sorry for the delay. Are you still blocked by this issue? I planned on adding a config option to specify this walk timeout (with a max of some not-yet-determined value)

smaye81 avatar Mar 06 '20 21:03 smaye81

I am blocked by issue. I can never run lint or format on my machine bc of this error.

mjamei avatar Mar 09 '20 13:03 mjamei

Yeah, we plan on adding a config option for the v1.10 release.

smaye81 avatar Mar 09 '20 15:03 smaye81

FWIW, this is turning into a showstopper for one of the projects that uses Apache Yetus' support for prototool. The workaround of putting the excludes in place doesn't appear to be working. (My main guess is the walktimeout still happens since the directory structure is very very large on top of using it within docker.) For that project, I'm going to likely recommend they start running a custom version of prototool with a more reasonable timeout value. :(

aw-was-here avatar Mar 23 '20 06:03 aw-was-here

I'm actually in the process of implementing this now. I planned on hopefully having it on the dev branch this week. I understand if you'd like to just do a custom version though.

smaye81 avatar Mar 23 '20 13:03 smaye81

@smaye81 I'm wondering how we should configure this walk-timeout configuration in prototool.yaml?

jeffreyyong avatar May 19 '20 12:05 jeffreyyong

This is actually a command line flag, not configured in prototool.yaml. So an example command is:

prototool lint --walk-timeout 10s

If you don't specify a walk-timeout the default is 3s.

smaye81 avatar May 19 '20 18:05 smaye81