-
Notifications
You must be signed in to change notification settings - Fork 12k
Improve logs and trace for [vite] Internal server error: undefined #30294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The culprit here is Could you please include a reproduction, as it's not entirely clear to me where the Vite error originates (i.e. client vs server) . The vite error stack trace seems somewhat unrelated to the invalid URL exception; it occurs during error logging presumably without error message. |
Hi ! Thanks for the quick response ! There is a short example for the Don't hesitate to request some more details. import { Component, Injectable } from '@angular/core';
import { AsyncPipe, NgIf } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { of } from 'rxjs';
import { catchError } from 'rxjs/operators';
@Injectable({
providedIn: 'root',
})
export class DataService {
private defaultResponse = "Hello world! Default message when not getting data"
constructor(private http: HttpClient) {}
getData(url:string) {
return this.http.get(url).pipe(
catchError(() => of(this.defaultResponse)),
);
}
}
@Component({
selector: 'app-root',
template: `
<div *ngIf="data$ | async as data">
<pre>{{ data }}</pre>
</div>
`,
imports: [
AsyncPipe,
NgIf
]
})
export class AppComponent {
private url = 'https://example.com'; // <=== Change value for an unvalid url like `http:` -> error appears
data$ = this.dataService.getData(this.url);
constructor(private dataService: DataService) {}
} Other imported file contents in my project : // main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
// app.config
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideClientHydration } from '@angular/platform-browser';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideClientHydration(),
provideHttpClient(withFetch())
]
};
// app.routes
import { Routes } from '@angular/router';
export const routes: Routes = []; |
I created a minimal CLI project with the above snippets, with the important note that SSR needs to be enabled. The vite errors
with the Interestingly, this stack trace occurs very frequently and no page load in a browser is required; I suppose this happens during pre-rendering of the root page, given that the following logging is output when changing the
/cc @alan-agius4 |
Hi, we have this similar error as in the original post after we updated our SSR app from Angular 17 to 19. There were no such errors in the update from 17 to 18, but shows up after updating to 19. We can't trace where this issue originates. Both errors below shows up in the console and the 2nd error shows up in the browser when the refresh fails: First:
Second:
The problem sort of "goes away" after forcing a browser refresh multiple times but when We don't have any similar code as @LeoWanty that might have cause it that we could try to debug and resolve. |
I did some digging and found that the root cause of the undefined error is the outdated Domino As for the issue with multiple logs, I still need to investigate that further. |
The DOMException implementation in Domino was legacy and has been removed. This code now uses the standard version of `DOMException`, which is also available natively in Node.js. Related to: angular/angular-cli#30294
The DOMException implementation in Domino was legacy and has been removed. This code now uses the standard version of `DOMException`, which is also available natively in Node.js. Related to: angular/angular-cli#30294
The DOMException implementation in Domino was legacy and has been removed. This code now uses the standard version of `DOMException`, which is also available natively in Node.js. Related to: angular/angular-cli#30294
I continued investigating and found that the excessive logs are caused by a recursive loop of requests. The issue occurs when an API call is made from new URL('http:', 'http://localhost:4200').href. //--> http://localhost:4200/ it resolves to This behavior results from how JavaScript's
|
Closed via angular/domino#22 and angular/angular#61302 |
Uh oh!
There was an error while loading. Please reload this page.
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
Hi,
I had a lot of troubles debuging a
[vite] Internal server error: undefined
caused by an unvalid url using theHttpClient
. The problem is more general though.The logs are far too unprecise to help finding the piece of code at fault. The traceback is not deep enough to recover the call sequence too. Plus, async calls and the observers nature make even more hazardous the use of
console.log
to investigate.In my case, I simply got such tracebacks at first :
At some point, I did remove a
catchError
in myHttpClient.get(url).pipe
by accident and discovered the cause of the previous error (see the missing/
in input):Notice that in the case of an HttpClient, it is very common to
catchError
to feed with default data. Like in the following:Proposed solution
If you have any way of making the logs or the traceback more explicit when vite fails with
Internal server error: undefined
, it would be of great help !Alternatives considered
If there is some tooling helping the debug of Vite, you may add some documentation or a blog post.
The text was updated successfully, but these errors were encountered: