Skip to content

Errors during serialization of TransferState not propagated #65811

@webberig

Description

@webberig

Which @angular/* package(s) are the source of the bug?

platform-server

Is this a regression?

No

Description

Due to an application error an unserializable exception object was passed to the TransferState service. This caused the exception below. Unfortunately, the error is being swallowed so the page returns a 200 OK without the transferstate <script id="ng-state" type="application/json"> snippet which in turn caused some issues for our website client-side.

The code containing the error handling is here:

// Ignore exceptions.

Ideally we have a way of handling this kind of error and produce an error page instead.

A page was returning a 200 OK response in a corrupted state. I noticed that the ng-state script snippet was missing in the response.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

The server logs mentioned following error:

   Ignoring BEFORE_APP_SERIALIZED Exception:  TypeError: Converting circular structure to JSON
       --> starting at object with constructor 'r'
       |     property 'upload' -> object with constructor 'b'
       --- property '_request' closes the circle
       at JSON.stringify (<anonymous>)
       at e.toJson (file:///app/dist/apps/web/server/chunk-7FR65NHR.mjs:5:31328)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 20.1.3
Node: 20.19.4
Package Manager: yarn 4.9.2
OS: darwin arm64

Angular: 20.1.3
... animations, build, cdk, cli, common, compiler, compiler-cli
... core, forms, language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router, ssr

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2001.3
@angular-devkit/core         20.1.3
@angular-devkit/schematics   20.1.3
@schematics/angular          19.0.7
ng-packagr                   19.0.1
rxjs                         7.8.1
typescript                   5.8.3
zone.js                      0.15.1

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: serverIssues related to server-side rendering

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions