Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

An unhandled exception occurred while processing the request #1234

Description

@chamikasandamal

I'm using dotnet core sdk 2.0 SPA template for angular. when running the application, i can see following error. This issue is there when it running through visual studio 2017 as well as when it published to azure.
But when i switch off the pre-rendering by removing asp-prerender-module="xxx", it is working fine.

WinHttpException: The connection with the server was terminated abnormally
Unknown location

IOException: The read operation failed, see inner exception.
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

HttpRequestException: Error while copying content to a stream.
System.Net.Http.HttpContent+<LoadIntoBufferAsyncCore>d__48.MoveNext()

Note: I'm using organizational account authentication

Activity

  1. SteveSandersonMS commented on Aug 30, 2017

    @SteveSandersonMS
    Member

    Hi @chamikasandamal - could you please post specific repro steps? If I create a new Angular project, what are the minimal code changes that result in this issue?

  2. chamikasandamal commented on Sep 1, 2017

    @chamikasandamal
    Author

    It seems following line of codes cause the issue. I had to check typeof window !== 'undefined' since it returns server time withe the pre-rendering. when i wrap the this.subscription.unsubscribe(); with same condition, error is gone.

        ngOnInit(): void {
            if (typeof window !== 'undefined') {            
                this.calculateTime();
                setInterval(() => {
                    this.calculateTime();
                }, 1000);
            }
        }
    
        public ngOnDestroy(): void {
            this.subscription.unsubscribe(); //<-- this caused the issue
        }
    

    Seems this can be consider as not a bug, but let's make error messages more meaningful.

  3. MarkPieszak commented on Sep 3, 2017

    @MarkPieszak
    Contributor

    You have to really be careful with setTimeouts and setIntervals because one will slow down your server render, while the other will cause it to never render, as it's waiting for all tasks to finish. Make sure you wrap these in inPlatformBrowser calls.

    More info here:
    https://github.com/angular/universal#universal-gotchas

  4. SteveSandersonMS commented on Sep 6, 2017

    @SteveSandersonMS
    Member

    Glad you tracked this down. As for the error message, when running in dev environment, normally you will get the exact error message rather than the generic "The connection with the server was terminated abnormally". If you did get the generic message when running in dev mode, do you have repro steps for that? Because it is supposed to give the underlying exception info in that case.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions