Thanks to visit codestin.com
Credit goes to github.com

Skip to content

httpResource.arrayBuffer causes [Object object] error with SSR #66827

@henrikse55

Description

@henrikse55

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

common

Is this a regression?

No

Description

When using httpResource.arrayBuffer and have SSR enabled the arraybuffer is not copied correctly and the client is hydrated initially with an arraybuffer with length of 15 - [Object object] is what is returned when doing TextDecoder().Decode

Image

the httpResource parse method is initially invoked with this 15 byte arraybuffer which can cause errors with custom parsers

This problem can be 'solved' be setting transferCache to false but you are now making 2 requests, 1 server - 1 client. it's also less ideal as data may have changed between those 2 requests occurring.

Please provide a link to a minimal reproduction of the bug

https://github.com/henrikse55/angular-httpresource-ssr

Please provide the exception or error you saw

None, it's completely silent and possibly breaks custom parse logic

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

Angular CLI       : 21.1.2
Angular           : 21.1.2
Node.js           : 20.19.5
Package Manager   : yarn 1.22.22
Operating System  : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.1.2            │ ^21.0.3           │
│ @angular/cli              │ 21.1.2            │ ^21.0.3           │
│ @angular/common           │ 21.1.2            │ ^21.0.0           │
│ @angular/compiler         │ 21.1.2            │ ^21.0.0           │
│ @angular/compiler-cli     │ 21.1.2            │ ^21.0.0           │
│ @angular/core             │ 21.1.2            │ ^21.0.0           │
│ @angular/forms            │ 21.1.2            │ ^21.0.0           │
│ @angular/platform-browser │ 21.1.2            │ ^21.0.0           │
│ @angular/platform-server  │ 21.1.2            │ ^21.0.0           │
│ @angular/router           │ 21.1.2            │ ^21.0.0           │
│ @angular/ssr              │ 21.1.2            │ ^21.0.3           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.0.18            │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

While excluded from the reproduction repo, httpResource.blob has the same issue in my experience

I noticed TransferState states dosen't support class types, this might be the cause?

I ran into this issue in a personal project exploring memorypack and generated ts types

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: common/httpIssues related to HTTP and HTTP Clientarea: serverIssues related to server-side rendering

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions