-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Angular v17 with Supabase freezes while ng serve or ng build #26395
Comments
Are you on Windows and is this related to introducing and then fixing errors during an |
@LukasKomar, I was not able to reproduce using the steps provided. Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via This might be related to your directory structure so its really important to get an accurate repro to diagnose this. |
@alan-agius4 I face the same issue here is a repro https://github.com/kaaai3/repro-supabase Line 12 in the file |
During prerendering a |
@kaaai3 did you find a solution to this? |
@halterdev Nope, not yet. |
@halterdev and @kaaai3 , set This is just a bandaid really, but it got me moving forward again. -- @alan-agius4 for SPA angular apps, I believe services use a singleton pattern. Is there a lifecycle for services with SSR where I can dispose of the supabase client? I couldn't find anything about that in the docs. |
@halterdev and @kaaai3 , I have an additional workaround. If you don't want to turn SSR off. The main issue here is due to the Server Side Rendering trying to open the supabase client and then getting stuck. So the solution below shows how to avoid creating the supabase client when in SSR and only create it in the browser. You will have to move the creation of the supabase client to another function and call it in your components constructor. export class SupabaseService {
private supabase: SupabaseClient | null = null
_session: AuthSession | null = null
constructor() {
}
initialize() {
this.supabase = createClient(environment.supabaseUrl, environment.supabaseKey);
}
} Then in your component export class AppComponent {
title = 'angular-user-management'
constructor(private readonly supabase: SupabaseService) {
afterNextRender(() => {
this.supabase.initialize();
})
}
} |
@davidboothe Thanks for the workaround. |
So I looked at this again, and the proper solution for this would be to initialise supabase outside of Zone.js context @Injectable({
providedIn: 'root',
})
export class DataService {
private supabase: SupabaseClient;
private readonly ngZone = inject(NgZone);
constructor() {
this.supabase = this.ngZone.runOutsideAngular(() =>
createClient(environment.supabaseUrl, environment.supabaseKey)
);
}
}
@Injectable({
providedIn: 'root',
})
export class DataService implements OnDestroy {
ngOnDestroy(): void {
// perform clean up.
}
} |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Command
build, serve
Is this a regression?
The previous version in which this bug was not present was
16
Description
Hey, I just created a new Angular 17 Application. After adding the latest supabase client the serve and build command will not work properly anymore.
Minimal Reproduction
ng new repro-app
npm install @supabase/supabase-js
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: