azure-pipelines-task-lib: Failed find: Maximum call stack size exceeded

vsts-task-lib 2.4.0 My task is looking for a file produced during the build. I know the name of the file (report-task.txt), but not its location. So I’m using:

tl.findMatch(
  tl.getVariable('Agent.BuildDirectory'),
  path.join('**', 'report-task.txt')
);

Unfortunately, when there are too many files in the build directory, it fails with:

2018-09-20T09:14:03.3401724Z ##[debug]Agent.BuildDirectory=C:\vsts-agent\agent\_work\2
2018-09-20T09:14:03.3401908Z ##[debug]defaultRoot: 'C:\vsts-agent\agent\_work\2'
2018-09-20T09:14:03.3402086Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2018-09-20T09:14:03.3402256Z ##[debug]findOptions.followSymbolicLinks: 'true'
2018-09-20T09:14:03.3402421Z ##[debug]matchOptions.debug: 'false'
2018-09-20T09:14:03.3402581Z ##[debug]matchOptions.nobrace: 'true'
2018-09-20T09:14:03.3402741Z ##[debug]matchOptions.noglobstar: 'false'
2018-09-20T09:14:03.3402899Z ##[debug]matchOptions.dot: 'true'
2018-09-20T09:14:03.3403057Z ##[debug]matchOptions.noext: 'false'
2018-09-20T09:14:03.3403299Z ##[debug]matchOptions.nocase: 'true'
2018-09-20T09:14:03.3403458Z ##[debug]matchOptions.nonull: 'false'
2018-09-20T09:14:03.3403624Z ##[debug]matchOptions.matchBase: 'false'
2018-09-20T09:14:03.3403783Z ##[debug]matchOptions.nocomment: 'false'
2018-09-20T09:14:03.3403946Z ##[debug]matchOptions.nonegate: 'false'
2018-09-20T09:14:03.3404108Z ##[debug]matchOptions.flipNegate: 'false'
2018-09-20T09:14:03.3404265Z ##[debug]pattern: '**\report-task.txt'
2018-09-20T09:14:03.3408591Z ##[debug]findPath: 'C:\vsts-agent\agent\_work\2'
2018-09-20T09:14:03.3408807Z ##[debug]statOnly: 'false'
2018-09-20T09:14:03.3410070Z ##[debug]findPath: 'C:\vsts-agent\agent\_work\2'
2018-09-20T09:14:03.3410294Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2018-09-20T09:14:03.3410479Z ##[debug]findOptions.followSymbolicLinks: 'true'
2018-09-20T09:14:03.3413368Z ##[debug]  C:\vsts-agent\agent\_work\2 (directory)
[...] (many files)
2018-09-20T09:14:09.9229553Z ##[debug][SQ] Publish task error: Failed find: Maximum call stack size exceeded
2018-09-20T09:14:09.9229867Z ##[debug]task result: Failed
2018-09-20T09:14:09.9230850Z ##[error]Failed find: Maximum call stack size exceeded
2018-09-20T09:14:09.9231251Z ##[debug]Processed: ##vso[task.issue type=error;]Failed find: Maximum call stack size exceeded
2018-09-20T09:14:09.9231740Z ##[debug]Processed: ##vso[task.complete result=Failed;]Failed find: Maximum call stack size exceeded

Would it be possible to fix the behavior?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Great! Thanks for helping me debug this. I’ll add a PR to fix this.

Ad. 1) The number of files in the scanner-report directory is correct:

PS C:\snip> Get-ChildItem D:\Build\snip\_work\3-backup\.sonarqube\out\.sonar\scanner-report | measure
Count    : 127295

Ad. 2) Patched code does not throw errors. Code:

//stack.push.apply(stack, childItems.reverse());
for (var i = childItems.length - 1; i >= 0; i--) {
    stack.push(childItems[i]);
}

Output:

##vso[task.debug]370009 results
##vso[task.debug]found 370009 paths
##vso[task.debug]applying include pattern
##vso[task.debug]adjustedPattern: 'D:\Build\snip\_work\3-backup\**/report-task.txt'
##vso[task.debug]1 matches
##vso[task.debug]1 final results

I am about to run SonarQube with the patched library to see whether it can be used as a workaround.

I can do that. The error is in the find() function. What kind of info should I log? For test, I have logged the stack.length (console.error("Stack length: " + stack.length)):

Stack length: 2530
Error: Failed find: Maximum call stack size exceededStack length: 2530
Error: Failed find: Maximum call stack size exceeded

I will play with it a bit and will report here if I find anything of interest, but let me know what would you be interested in?

It’s getting late here, so I will probably continue investigation tomorrow morning.