SuessLabs / VsLinuxDebug

VS Extension to remotely deploy and debug your .NET (Core) C# solutions directly to your Linux or Raspberry Pi devices! .NET Core 3.1, .NET 5, 6, 7, 8, 9
https://marketplace.visualstudio.com/items?itemName=SuessLabs.VSLinuxDebugger
MIT License
36 stars 8 forks source link

Error while uploading file #58

Closed HakanL closed 1 year ago

HakanL commented 1 year ago

Description

Getting this error:

Error while uploading file. Object reference not set to an instance of an object.
   at VsLinuxDebugger.Core.SshTool.<>c__DisplayClass22_0.<PayloadCompressAndUploadAsync>b__1()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at VsLinuxDebugger.Core.SshTool.<PayloadCompressAndUploadAsync>d__22.MoveNext()

Severity (1-5)

1=Low (annoyance), 5=High (crashes visual studio) 4 - can't use the extension

Steps To Reproduce

Steps to reproduce the behavior: I'm just clicking deploy and it happens during upload

Expected Behavior

The upload should be successful

Output

22:02:24.706: Project [success=True]: ..\..\MagnusEngine\MagnusEngine\MagnusEngine.csproj
22:02:24.801: Project [success=True]: BusinessLogic\BusinessLogic.csproj
22:02:25.451: Project [success=True]: DMXCore100.Linux\DMXCore100.Linux.csproj
22:02:25.475: Build was successful
22:02:31.411: Connected to root@a487250.local:22 via SSH and SCP
22:02:31.596: BASH> uname -m
22:02:31.615: BASH> which curl ; echo $?
22:02:31.631: BASH> [ -d ~/.vs-debugger/vs2022 ] || curl -ksSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/.vs-debugger/vs2022
22:02:31.645: Returned: 
22:02:31.645: BASH> mkdir -p ./VSLinuxDbg
22:02:31.662: BASH> sudo chown -R root ./VSLinuxDbg
22:02:31.702: BASH> rm -rf ./VSLinuxDbg/DMXCore100.Linux/{*,.*}
22:02:31.717: BASH> mkdir -p ./VSLinuxDbg/DMXCore100.Linux
22:02:31.732: Destination Tar.GZ: './VSLinuxDbg/DMXCore100.Linux/vsldBuildContents.tar.gz'
22:02:31.732: Getting bin files for transfer...
22:02:31.761: Compressing files for transfer...
22:02:52.276: Update file count: 572; File Size: [233597785 bytes] of Total Files: 572 [233597785 bytes] need to be updated
22:02:52.276: Uploading...
22:02:52.277: Error while uploading file. Object reference not set to an instance of an object.
   at VsLinuxDebugger.Core.SshTool.<>c__DisplayClass22_0.<PayloadCompressAndUploadAsync>b__1()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at VsLinuxDebugger.Core.SshTool.<PayloadCompressAndUploadAsync>d__22.MoveNext()
22:02:52.277: BASH> set -e;cd "./VSLinuxDbg/DMXCore100.Linux";tar -zxf "vsldBuildContents.tar.gz"
22:02:52.300: Payload Decompress results: '' (blank=OK)
22:02:52.300: Upload completed with failure.

Linux Distribution:

BalenaOS

Additional Context

Add any other context about the problem here.

HakanL commented 1 year ago

Sometimes if I retry it works, with nothing changed.

DamianSuess commented 1 year ago

@HakanL, seeing that I'm not familiar with BalenaOS, there are a variety of remote-side causes that could be triggering this. None the less, let's work through this and see what we can do.

Your issue appears to be happening right at this point (SshToo.cs - Lines 487-493). This is where I'm calling Renci.SshNet's SFTP to perform the upload.

Since this is happening "sometimes" triggers the question, is the remote OS dropping the SFTP connection?

            Logger.Output("Uploading...");
            await Task.Run(() =>
            {
              tarGzStream.Seek(0, SeekOrigin.Begin);

              sftp.UploadFile(tarGzStream, pathBuildTarGz);
            });

            Logger.Output($"Uploaded '{_tarGzFileName}' [{tarGzSize,13:n0} bytes].");
HakanL commented 1 year ago

Which version of the extension are you using? (assuming the latest published) Yes, latest published

Are you able to test/validate connectivity using SFTP via a 3rd-party tool? I haven't tested this, but I'm SSH:d to the device (using putty)

Are you connected to a physical device or virtualized one? It's a physical Raspberry Pi CM4, but it's running docker so I'm attempting to deploy to a guest instance in docker (and that's where I'm also SSH:d into). But it works intermittently.

How would I see if the remote OS drops the SFTP connection?

HakanL commented 1 year ago

It may have been an issue with my Raspberry Pi, it's been working fine now for a while, so I'll close this issue.

HakanL commented 1 year ago

However it would be good to properly catch and report the error, instead of null-ref :)

DamianSuess commented 1 year ago

None the less, we can get in that checking mechanism. Definitely don't like seeing unexpected errors