New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for debugger flag for .NET Core 2.0 / 2.1 implementation #130

Merged
merged 5 commits into from Dec 5, 2018

Conversation

Projects
None yet
2 participants
@ndobryanskyy
Copy link
Contributor

ndobryanskyy commented Nov 20, 2018

Original issue

#125 - issue, that requests .NET Core 2.0 / 2.1 debugging support

Changes

  • Added DebuggerExtensions class which enables waiting for the debugger to attach in the loop, inspecting Debugger.IsAttached property with interval (50ms). Also it has 10 minutes timeout, after it, function will continue executing without debugging;
  • Added --debugger-spin-wait flag handling, if it supplied as an argument, then, we will use DebuggerExtensions.TryWaitForAttaching to wait for the debugger before proceeding to execution;
  • Added try / catch block for all body of Main to prevent user from hanging on External Code Exception while debugging.

Side note

I've closed #127 as it had a lot of unnecessary stuff. Now this PR has only required changes, to proceed with #125.

{
Console.Error.WriteLine(lambdaException);

This comment has been minimized.

@mhart

mhart Dec 3, 2018

Member

I don't understand this change

This comment has been minimized.

@ndobryanskyy

ndobryanskyy Dec 3, 2018

Contributor

I've added "\nUnhandled exception occured in runner:\n" to better constraint the exception origin for the user, while he is debugging. And outer try/catch block is used to prevent user from hanging on unhandled exception from the runnner program.

@mhart does it make sense?

This comment has been minimized.

@mhart

mhart Dec 3, 2018

Member

I don't think so – I think it'd be better to match the behaviour of the rest of the runtimes w/ regards to error output. So errors should look the same as they do on Lambda itself.

If it doesn't currently do that (it might not by the looks of it) – then we should change it so that it does 👍

This comment has been minimized.

@ndobryanskyy

ndobryanskyy Dec 3, 2018

Contributor

You don't like the string, or how it behaves?

This comment has been minimized.

@ndobryanskyy

ndobryanskyy Dec 3, 2018

Contributor

issue

On this sample I've misused Lambda runner and got stuck on unhandled exception (default dotnet debugger behavior), that is why I have try/catch block around all the invocation.

This sample was run on unmodified version of lambci/lambda:dotnetcore2.1

@mhart Did I make my point clear?

This comment has been minimized.

@ndobryanskyy

ndobryanskyy Dec 3, 2018

Contributor

How about --debugger-spin-wait ?

This comment has been minimized.

@mhart

mhart Dec 3, 2018

Member

Yup, happy with that! 👍

This comment has been minimized.

@ndobryanskyy

ndobryanskyy Dec 3, 2018

Contributor

Updated according to comments

This comment has been minimized.

@mhart

mhart Dec 3, 2018

Member

Great, I'm happy with that, feel free to update your SAM CLI PR 👍

I'll explore this PR more in the next couple of days, but I think the rest of it looks pretty good

This comment has been minimized.

@ndobryanskyy

ndobryanskyy Dec 3, 2018

Contributor

Great, take your time @mhart

@ndobryanskyy ndobryanskyy referenced this pull request Dec 4, 2018

Merged

Feature: .NET Core 2.0/2.1 debugging support #825

6 of 6 tasks complete

@mhart mhart merged commit 26f9f37 into lambci:master Dec 5, 2018

@mhart

This comment has been minimized.

Copy link
Member

mhart commented Dec 5, 2018

Thanks so much for this @ndobryanskyy – it looks great!

I've already pushed images up at lambci/lambda:dotnetcore2.0 and lambci/lambda:dotnetcore2.1 with these changes – have fun debugging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment