aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

Lambda suddenly started to throw error

Open genifycom opened this issue 9 years ago • 27 comments

I was running a lambda ASP.NET Core application successfully when suddenly it started to thow:

Could not find file '/var/lang/Microsoft.NETCore.App.deps.json'.: FileNotFoundException

I was having a couple of people try hitting it at the same time. Is this to do with starting a new instance?

Thanks, Dave

genifycom avatar May 11 '17 21:05 genifycom

Can you provide the full exception stack trace? How frequently does this occur? Which region did you use?

gokarnm avatar May 11 '17 21:05 gokarnm

I have also been getting this since yesterday!! Thought I was going crazy... its tentatively working for me again as of evening 8:30 PST

Was happening in us-west-2 for me. It was almost completely constant. I have been combing through library versions thinking there was some sort of mismatch. The stack-trace was pretty useless- happens in services.UseMvcCore(). I am pretty convinced now its an AWS issue since i'm not the only one.

automagic avatar May 12 '17 03:05 automagic

@automagic , thanks for the details! Could you share the stack trace, it would be helpful to diagnose the issue.

gokarnm avatar May 12 '17 03:05 gokarnm

An exception was thrown when the constructor for type 'PlatformAPI.LambdaFunction' was invoked. Check inner exception for more details.: LambdaException


at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
Could not find file '/var/lang/Microsoft.NETCore.App.deps.json'.: FileNotFoundException
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Interop.CheckIo[TSafeHandle](TSafeHandle handle, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Microsoft.Extensions.DependencyModel.FileWrapper.OpenRead(String path)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadRuntimeContext(IDependencyContextReader reader)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at PlatformAPI.Startup.ConfigureServices(IServiceCollection services)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction..ctor()
at PlatformAPI.LambdaFunction..ctor()

automagic avatar May 12 '17 03:05 automagic

Thanks for the stack trace! We are looking into this issue. @genifycom , @automagic , would you be able to share a trimmed down/sample ASP.NET Core app that triggers this error?

gokarnm avatar May 12 '17 04:05 gokarnm

I will look into getting you a sample app tomorrow morning.

automagic avatar May 12 '17 04:05 automagic

region:us-east-1

I can force the exception. Subsequent calls to the function will fail until I update an environment variable, forcing a reload of the "machine?".

An exception was thrown when the constructor for type 'Swell.AspNetCore.LambdaEntryPoint' was invoked. Check inner exception for more details.: LambdaException

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) Could not find file '/var/lang/Microsoft.NETCore.App.deps.json'.: FileNotFoundException at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) at Interop.CheckIo[TSafeHandle](TSafeHandle handle, String path, Boolean isDirectory, Func2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at Microsoft.Extensions.DependencyModel.FileWrapper.OpenRead(String path) at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadRuntimeContext(IDependencyContextReader reader) at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly) at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName) at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services, Action1 setupAction) at Microsoft.Extensions.DependencyInjection.IServiceCollectionExtensions.AddApiVersioning(IServiceCollection services, Action1 setupAction) at Swell.AspNetCore.Startup.ConfigureServices(IServiceCollection services) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction..ctor()

pfeurean avatar May 12 '17 16:05 pfeurean

@pfeurean exactly how mine acts. It kills the function until a new container is instantiated (Lambda is just Docker underneath)

Also I have an enterprise support ticket out with AWS about this, so I will keep this thread updated with the response there as well.

automagic avatar May 12 '17 16:05 automagic

I've got this same issue. It seems to work for a period of time right after deployment but after a few mins it starts throwing the same FileNotFoundException that everyone is having. Hopefully this gets sorted out soon.

DerrickF avatar May 12 '17 16:05 DerrickF

I'm seeing the exact same behavior. I've been pulling my hair out over for it for > 24 hours now.

Stack trace here:

An exception was thrown when the constructor for type 'LeadEngineASP.LambdaEntryPoint' was invoked. Check inner exception for more details.: LambdaException
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
Exception has been thrown by the target of an invocation.: TargetInvocationException
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection exportServices)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction..ctor()
Could not find file '/var/lang/Microsoft.NETCore.App.deps.json'.: FileNotFoundException
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Interop.CheckIo[TSafeHandle](TSafeHandle handle, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Microsoft.Extensions.EnvironmentAbstractions.FileWrapper.OpenRead(String path)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadRuntimeContext(IDependencyContextReader reader)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
at LeadEngineASP.Startup.ConfigureServices(IServiceCollection services)

jnb-source avatar May 12 '17 16:05 jnb-source

We are actively working this issue and will have a fix soon. @genifycom , @DerrickF , @JNBarnes which regions are you using?

gokarnm avatar May 12 '17 17:05 gokarnm

@gokarnm eu-west1. I'm putting together an SCCE for you to help repro it too...

jnb-source avatar May 12 '17 17:05 jnb-source

@gokarnm us-west2

DerrickF avatar May 12 '17 18:05 DerrickF

AWS Support is also aware (from my ticket):

Hello,

The Lambda team is aware of the issue and currently taking steps to address it. A fix should be applied shortly.

automagic avatar May 12 '17 19:05 automagic

We are experiencing the same issue (since 23:33 UTC) in US-East-1

An exception was thrown when the constructor for type 'redacted' was invoked. Check inner exception for more details.: LambdaException

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) Exception has been thrown by the target of an invocation.: TargetInvocationException at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection exportServices) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction..ctor() Could not find file '/var/lang/Microsoft.NETCore.App.deps.json'.: FileNotFoundException at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) at Interop.CheckIo[TSafeHandle](TSafeHandle handle, String path, Boolean isDirectory, Func2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at Microsoft.Extensions.EnvironmentAbstractions.FileWrapper.OpenRead(String path) at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadRuntimeContext(IDependencyContextReader reader) at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly) at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName) at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services) at wv3.fieldFlowAPI.Startup.ConfigureServices(IServiceCollection services)

lthompson-cartasite avatar May 12 '17 19:05 lthompson-cartasite

A fix has been released for Lambda to address this issue. Please update this thread if you still encounter this error.

gokarnm avatar May 13 '17 17:05 gokarnm

Thanks! Any chance you could give us any technical insight into what went wrong on the lambda end?

automagic avatar May 15 '17 17:05 automagic

We are working on an in-depth analysis of what went wrong and how to prevent this in the future, there should be an update with details in a week.

gokarnm avatar May 15 '17 20:05 gokarnm

Hi @automagic , @JNBarnes , I've sent a PM over gitter to get some details about your application.

gokarnm avatar May 23 '17 00:05 gokarnm

Here are the details of the bug, closing this issue.

Starting 5/9/2017, AWS Lambda deployed an update for .NET Core 1.0 runtime. The update allowed libraries like Microsoft.Extensions.DependencyModel to pick up the correct path for application and framework dependencies files (.deps.json). An example of usage of the dependency files is the ASP.NET Core Razor pages that are dynamically compiled, which uses these files to discover the dependencies at runtime.

The Microsoft.NETCore.App.deps.json file, which is the framework dependency file, was missing in the runtime environment, which caused code paths in ASP.NET applications to fail. We got an initial report of this bug on 5/11/2017 on this GitHub issue, and received additional reports through AWS Forums and AWS Support tickets on 5/12/2017. After the issue was reported, we started a rollback of the update on 5/12/2017 and completed rollback in all regions by 5/13/2017. The root cause was identified to be a bug that resulted in the Microsoft.NETCore.App.deps.json file to be absent in the runtime environment. An internal review of the events that caused this issue, and corrective actions is underway. As part of corrective actions, we are adding additional tests and checks in place to prevent similar issues in the future.

gokarnm avatar Jun 12 '17 17:06 gokarnm