Skip to content

vite dev server crashes when server return 502 #26192

Closed
@zip-fa

Description

@zip-fa

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Hi.
My dev server crashes when HttpClient receives 502 error from backend REST api.
If you need repro - please let me know.

Minimal Reproduction

ng serve

Exception or Error

/.angular/vite-root/8255c350-0f5c-4412-a828-cfc1d8e3960e/polyfills.server.mjs:175
            throw error;
            ^
HttpErrorResponse {
  headers: HttpHeaders {
    normalizedNames: Map(13) {
      'access-control-allow-origin' => 'access-control-allow-origin',
      'cache-control' => 'cache-control',
      'cf-ray' => 'cf-ray',
      'connection' => 'connection',
      'content-length' => 'content-length',
      'content-type' => 'content-type',
      'date' => 'date',
      'expires' => 'expires',
      'nel' => 'nel',
      'referrer-policy' => 'referrer-policy',
      'report-to' => 'report-to',
      'server' => 'server',
      'x-frame-options' => 'x-frame-options'
    },
    lazyUpdate: null,
    headers: Map(13) {
      'access-control-allow-origin' => [ '*' ],
      'cache-control' => [
        'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
      ],
      'cf-ray' => [ '81f35df6af634c80-HEL' ],
      'connection' => [ 'close' ],
      'content-length' => [ '6307' ],
      'content-type' => [ 'text/html; charset=UTF-8' ],
      'date' => [ 'Wed, 01 Nov 2023 10:13:46 GMT' ],
      'expires' => [ 'Thu, 01 Jan 1970 00:00:01 GMT' ],
      'nel' => [
        '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
      ],
      'referrer-policy' => [ 'same-origin' ],
      'report-to' => [
        '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/"}],"group":"cf-nel","max_age":604800}'
      ],
      'server' => [ 'cloudflare' ],
      'x-frame-options' => [ 'SAMEORIGIN' ]
    }
  },
  status: 502,
  statusText: 'Bad Gateway',
  url: 'http://127.0.0.1:4000/api/status',
  ok: false,
  name: 'HttpErrorResponse',
  message: 'Http failure response for http://127.0.0.1:4000/api/status: 502 Bad Gateway',
  error: SyntaxError: Unexpected token < in JSON at position 0
      at JSON.parse (<anonymous>)
      at FetchBackend.parseBody (file:///C:/node_modules/@angular/common/fesm2022/http.mjs:1546:50)
      at FetchBackend.doRequest (file:///C:/node_modules/@angular/common/fesm2022/http.mjs:1496:29)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

Node.js v18.18.1

Your Environment

Angular CLI: 17.0.0-rc.3
Node: 18.18.1
Package Manager: npm 9.8.1
OS: win32 x64

Angular: 17.0.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0-rc.3
@angular-devkit/build-angular   17.0.0-rc.3
@angular-devkit/core            17.0.0-rc.3
@angular-devkit/schematics      17.0.0-rc.1
@angular/cdk                    17.0.0-next.6
@angular/cli                    17.0.0-rc.3
@angular/material               17.0.0-rc.0
@angular/ssr                    17.0.0-next.9
@schematics/angular             16.2.5
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions