Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 440 forks source link

C# compilation service error: The operation was canceled. #2098

Open ahmelsayed opened 6 years ago

ahmelsayed commented 6 years ago

I have been seeing this error randomly when having a C# compile error. I'm pretty sure I saw it on both Windows and Linux

2017-11-01T23:35:13.676 Microsoft.Azure.WebJobs.Script.Description.CompilationServiceException : C# compilation service error: The operation was canceled. ---> System.OperationCanceledException : The operation was canceled.
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive,Int32 toExclusive,ParallelOptions parallelOptions,Action`1 body,Action`2 bodyWithState,Func`4 bodyWithLocal,Func`1 localInit,Action`1 localFinally)
   at System.Threading.Tasks.Parallel.For(Int32 fromInclusive,Int32 toExclusive,ParallelOptions parallelOptions,Action`1 body)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDiagnostics(CompilationStage stage,Boolean includeEarlierStages,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods(CommonPEModuleBuilder moduleBuilder,Boolean emittingPdb,Boolean emitMetadataOnly,Boolean emitTestCoverageData,DiagnosticBag diagnostics,Predicate`1 filterOpt,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Compilation.Emit(Stream peStream,Stream metadataPEStream,Stream pdbStream,Stream xmlDocumentationStream,Stream win32Resources,IEnumerable`1 manifestResources,EmitOptions options,IMethodSymbol debugEntryPoint,Stream sourceLinkStream,IEnumerable`1 embeddedTexts,CompilationTestData testData,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Compilation.Emit(Stream peStream,Stream pdbStream,Stream xmlDocumentationStream,Stream win32Resources,IEnumerable`1 manifestResources,EmitOptions options,IMethodSymbol debugEntryPoint,Stream sourceLinkStream,IEnumerable`1 embeddedTexts,Stream metadataPEStream,CancellationToken cancellationToken)
   at async Microsoft.Azure.WebJobs.Script.Description.CSharpCompilation.EmitAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\Compilation\CSharp\CSharpCompilation.cs : 103 
   End of inner exception
   at async Microsoft.Azure.WebJobs.Script.Description.CSharpCompilation.EmitAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\Compilation\CSharp\CSharpCompilation.cs : 121
   at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 304
   at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader`1.GetFunctionTargetAsync[T](Int32 attemptCount) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionLoader.cs : 0
   at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetFunctionTargetAsync() at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 185
2017-11-01T23:35:13.676 Function loader reset. Failed compilation result will not be cached.
paulbatum commented 6 years ago

I think this exception can happen when there is a race between sending a compilation to roslyn and having a host restart occur. looks like we should swallow this exception.