Skip to content
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

Acquiring an exclusive Navigator LockManager failed #936

Open
2 tasks done
supersu-man opened this issue Jan 2, 2024 · 53 comments
Open
2 tasks done

Acquiring an exclusive Navigator LockManager failed #936

supersu-man opened this issue Jan 2, 2024 · 53 comments
Labels
bug Something isn't working

Comments

@supersu-man
Copy link

supersu-man commented Jan 2, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Angular throws an error saying 'Acquiring an exclusive Navigator LockManager lock immediately failed'.
This is a new angular project created with the angular version 17.
The error is not shown in my other project which is created a month ago.

To Reproduce

  1. Create a new angular project and install '@supabase/supabase-js'
  2. Create environment files and add key and url of supabase.
  3. add supabaseClient = createClient(environment.url, environment.key) to a component (app component)

Expected behavior

This error should not be thrown and should be able to use all the methods without errors.

Screenshots

Error

System information

  • OS: Windows
  • Browser: Brave v1.61.109
  • Version of supabase-js: 2.39.2
  • Version of Node.js: 20.10.0

Additional context

Could be a duplicate of this issue from gotrue-js.
Though I was able to signin using provider 'google' I wasn't able to retrieve session after I signin (throws an error saying Invalid API key) though my api keys and url are correct. I am assuming the error is with storage.

@supersu-man supersu-man added the bug Something isn't working label Jan 2, 2024
@Klunk75
Copy link

Klunk75 commented Jan 6, 2024

Hi there,
I noticed the same problem.
After some test I found that the issue should be related to the merge of this Pull Request in @supabase/gotrue-js version 2.62.0:
supabase/auth-js#807
If you try to downgrade @supabase/gotrue-js to version 2.61.0 (the previous one), the problem should disappear.
Please Supabase Team can you check and try to solve this issue?
Thank you!

Paolo

@supersu-man
Copy link
Author

If you try to downgrade @supabase/gotrue-js to version 2.61.0 (the previous one), the problem should disappear.

Thank you @Klunk75 for the workaround.

For anyone who wants to fix it temporarily, add this below devDependencies in package.json

"overrides": {
    "@supabase/supabase-js": {
      "@supabase/gotrue-js": "2.61.0"
    }
  }

and run npm i

@hf
Copy link
Contributor

hf commented Jan 16, 2024

Is this error just being logged, or is it actually creating a problem for you?

@supersu-man
Copy link
Author

Is this error just being logged, or is it actually creating a problem for you?

Sorry for the late reply. I don't think I am facing any issue, it's just the errors being logged.

@dimeloper
Copy link

In case you use pnpm as your dependency manager and you're facing the same issue, you can fix it by adding the following in your package.json:

"pnpm": {
    "overrides": {
      "@supabase/supabase-js>@supabase/gotrue-js": "2.61.0"
    }
  },

@mikelhamer
Copy link

seeing this with supabase 2.39.7, angular 17.2.1

@linhub15
Copy link

Seeing this with supabase 2.39.7
Reproduced with Chrome 121.0.6167.184 (Official Build) (64-bit)
Reproduced with Safari 16.6 (18615.3.12.11.2)
Unable to reproduce with Firefox 123.0 (64-bit).

// login.tsx
await supabase.auth.signInWithOAuth({
  provider: "google",
});

// index.tsx
const session = await supabase.auth.getSession();  // session is null

image

Overriding gotrue-js to "2.61.0" fixed it.

mariorobles93 added a commit to mariorobles93/Card-Info-Angular that referenced this issue Mar 17, 2024
@danielehrhardt
Copy link

If you try to downgrade @supabase/gotrue-js to version 2.61.0 (the previous one), the problem should disappear.

Thank you @Klunk75 for the workaround.

For anyone who wants to fix it temporarily, add this below devDependencies in package.json

"overrides": {
    "@supabase/supabase-js": {
      "@supabase/gotrue-js": "2.61.0"
    }
  }

and run npm i

maybe you can merge that

didoslavov added a commit to didoslavov/cook-it that referenced this issue Mar 25, 2024
@vv001
Copy link

vv001 commented Mar 29, 2024

I have tried the override approach, with gotrue version 2.61.1 and version 2.54.2, but still keep getting the same error as in the original post.

Will this issue be resolved anytime soon or are there other alternatives to the workaround?

Using angular 17.0.7

@matheo
Copy link

matheo commented Mar 30, 2024

@vv001 the override worked for me with @supabase/[email protected] but for version 2.41.1 it seems that gotrue was renamed to authjs and then I updated the override and it worked!

for pnpm:

"overrides": {
    "@supabase/supabase-js>@supabase/auth-js": "2.61.0"
}

and for npm should look like:

"overrides": {
  "@supabase/supabase-js": {
    "@supabase/auth-js": "2.61.0"
  }
}

@vv001
Copy link

vv001 commented Mar 30, 2024

Hi martheo, that did the trick. Thank you very much!

@ibarraandre98
Copy link

@matheo your solution worked for me, thanks!

@aroman25
Copy link

@matheo - thanks! this worked for me and then I updated supabase for the signInAnonymously and now getting this error again, can you work your magic again for the latest @supabase/supabase-js 2.42.5?

@wszgrcy
Copy link

wszgrcy commented Apr 22, 2024

@matheo - thanks! this worked for me and then I updated supabase for the signInAnonymously and now getting this error again, can you work your magic again for the latest @supabase/supabase-js 2.42.5?

same bug.....want use signInAnonymously.
I temporarily avoided this issue by using the ng18 zoneless mode
But zoneless is an experimental feature that may lead to other unknown issues

@matheo
Copy link

matheo commented Apr 23, 2024

@aroman25 @wszgrcy weird because I just upgraded it and the same override worked for me 🤔
in your lock file is there a @supabase/auth-js different than 2.61.0?

@ThirzaNL
Copy link

ThirzaNL commented Apr 23, 2024

I had the same issue as @aroman25 and @wszgrcy , and I've solved it using a patch.

Let me preface by saying that I don't know the inner workings of Supabase at all, and I have not tested it thoroughly, so use it at your own risk.

Basically, it just removes the navigatorLock parts, as that's seemingly causing the error.

When using this, the override of the package version is no longer needed, besides pinning it to the patched version.

@aroman25
Copy link

@wszgrcy - Yeah, that worked, also not a fan of it being experimental, but seems like v18 will have zoneless coming out next month

@matheo - 2.61.0 doesn't have the ability to signInAnonymously( )

@ThirzaNL - thanks, I'll wait for a fix, I can get by for now

@alcaidio
Copy link

alcaidio commented May 10, 2024

Same problem with Angular 17.3.0 and pnpm, I don't know why but I can't solve the problem...even with overrides in package.json and rm -rf node_modules && rm -rf pnpm-lock.yaml && pnpm i

@woutersteven
Copy link

woutersteven commented May 10, 2024

It may be useful for others, for me it is working for me on Angular 17.3.8 and npm with the following in package.json:

  "dependencies": {
    "@supabase/supabase-js": "2.43.1",
  },
  "devDependencies": {
    "supabase": "^1.167.1",
  },
  "overrides": {
    "@supabase/supabase-js": {
      "@supabase/auth-js": "2.61.0"
    }
  },

I just pasted what seemed relevant

@nicetomytyuk
Copy link

Any update on it?

I have "@supabase/supabase-js": "^2.43.4" and auth-js is 2.64.2 and still having that issue:

image

@macgors
Copy link

macgors commented Jun 23, 2024

I have the same problem with supabase-js 2.43.5 and angular 18.0.5

@francocores
Copy link

@macgors maybe this could fix your problem

for me it's working on angular 18 with ssr but I need do a workaround on localhost (I'm not sure if this problem happens on https environment):

my service

@Injectable({
  providedIn: 'root',
})
export class SupabaseService {
  private supabase?: SupabaseClient
  _session: AuthSession | null = null


  constructor() {
    this.createClient()
  }

  createClient() {
    if (typeof window === 'undefined' || createClient === undefined) return
    this.supabase = createClient(environment.supabaseUrl, environment.supabaseKey)
  }

  categories() {
    return this.supabase?.from('angular_test_categories').select(`id, name`)
  }
}

my package.json

"dependencies": {
    ...
    "@angular/core": "^18.0.0",
    "@angular/ssr": "^18.0.7",
    ...
    "@supabase/supabase-js": "2.39.2",
  },
  "overrides": {
    "@supabase/supabase-js": {
      "@supabase/gotrue-js": "2.61.0"
    }
  },

rileythomp added a commit to rileythomp/jeopardy that referenced this issue Jul 16, 2024
* override @supabase/auth-js dependency from v2.64.2 to v2.61.0 to resolve supabase/supabase-js#936

* update two way binding in profile visibility to work with angular 18

* redirect to /join if player is not authenticated within the game

* remove logs

* update console messages
@mungo-pod
Copy link

Bumping, still can't get it to work even with overrides, Was on Angular 18 and downgraded to 17.3.8 per one of the comments above, but no luck. here's the loadout.

"dependencies": {
    "@supabase/supabase-js": "2.39.2",
  },
  "devDependencies": {
    "supabase": "^1.167.1",
  },
  "overrides": {
    "@supabase/supabase-js": {
      "@supabase/gotrue-js": "2.61.0"
    }
  }

@TRUSTMEIMJEDI
Copy link

Any plans on fixing this issue in near future?

@machariaz
Copy link

I am using Angular 18 and the issue still persist even after trying to fix using the above recommendations

@AlexisMelo
Copy link

AlexisMelo commented Aug 14, 2024

@vv001 the override worked for me with @supabase/[email protected] but for version 2.41.1 it seems that gotrue was renamed to authjs and then I updated the override and it worked!

for pnpm:

"overrides": {
    "@supabase/supabase-js>@supabase/auth-js": "2.61.0"
}

and for npm should look like:

"overrides": {
  "@supabase/supabase-js": {
    "@supabase/auth-js": "2.61.0"
  }
}

this temporary solution worked for me

  • angular 18.1.3
  • supabase-js 2.45.1

@RyannGalea
Copy link

FYI this is what resolved it for me with yarn.

  "resolutions": {
    "@supabase/auth-js": "2.61.0"
  }

@PrettyJuice
Copy link

With Supabase 2.45.2 and Angular 18.2.1, the problem still persist.

FYI this is what resolved it for me with yarn.

  "resolutions": {
    "@supabase/auth-js": "2.61.0"
  }

This works, I hope it is a short time temporarily solution

@kleytonroan
Copy link

With Supabase 2.45.2 and Angular 18.2.1, the problem still persist.

FYI this is what resolved it for me with yarn.

  "resolutions": {
    "@supabase/auth-js": "2.61.0"
  }

This works, I hope it is a short time temporarily solution

I tried all the alternatives here, but none of them worked for me, since I'm using the new feature called anonymous authentication, which prevents me from changing the resolutions for version 2.61.0.

I had no time to test others versions

@lennybakkalian
Copy link

Very annoying that this issue has been lying around for so long and is being ignored.
Workaround could be to disable locking, but idk how big the side effects are.

createBrowserClient('', '', {
  auth: { lock: (_, __, fn) => fn() }
});

@alcaidio
Copy link

Why doesn’t the Supabase team address these issues? The problem has been ongoing for quite some time. I love Supabase, but I’m also a big fan of Angular. It's disappointing that the Angular community doesn’t seem to be a priority for Supabase.

@Bforsyth1234
Copy link

I would also like this issue to get some love.

@Picoquio
Copy link

Why doesn’t the Supabase team address these issues? The problem has been ongoing for quite some time. I love Supabase, but I’m also a big fan of Angular. It's disappointing that the Angular community doesn’t seem to be a priority for Supabase.

It's sad to see most of the new players treating Angular as a second class citizen when it's megaparsecs superior to React in almost every aspect

@francocores
Copy link

@macgors maybe this could fix your problem

for me it's working on angular 18 with ssr but I need do a workaround on localhost (I'm not sure if this problem happens on https environment):

my service

@Injectable({
  providedIn: 'root',
})
export class SupabaseService {
  private supabase?: SupabaseClient
  _session: AuthSession | null = null


  constructor() {
    this.createClient()
  }

  createClient() {
    if (typeof window === 'undefined' || createClient === undefined) return
    this.supabase = createClient(environment.supabaseUrl, environment.supabaseKey)
  }

  categories() {
    return this.supabase?.from('angular_test_categories').select(`id, name`)
  }
}

my package.json

"dependencies": {
    ...
    "@angular/core": "^18.0.0",
    "@angular/ssr": "^18.0.7",
    ...
    "@supabase/supabase-js": "2.39.2",
  },
  "overrides": {
    "@supabase/supabase-js": {
      "@supabase/gotrue-js": "2.61.0"
    }
  },

I'm using the version 2.44.4 on Angular 18 and it's working without override

package.json

"dependencies": {
    "@angular/animations": "^18.0.0",
    "@angular/cdk": "^18.0.6",
    "@angular/common": "^18.0.0",
    "@angular/compiler": "^18.0.0",
    "@angular/core": "^18.0.0",
    "@angular/forms": "^18.0.0",
    "@angular/platform-browser": "^18.0.0",
    "@angular/platform-browser-dynamic": "^18.0.0",
    "@angular/platform-server": "^18.0.0",
    "@angular/router": "^18.0.0",
    "@angular/ssr": "^18.0.7",
    "@supabase/supabase-js": "2.44.4",
    "chart.js": "4.4.4",
    "date-fns": "^3.6.0",
    "express": "^4.18.2",
    "primeflex": "^3.3.1",
    "primeicons": "^7.0.0",
    "primeng": "^17.18.5",
    "rxjs": "~7.8.0",
    "swiper": "11.1.11",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^18.0.7",
    "@angular/cli": "^18.0.7",
    "@angular/compiler-cli": "^18.0.0",
    "@types/chart.js": "^2.9.41",
    "@types/express": "^4.17.17",
    "@types/jasmine": "~5.1.0",
    "@types/node": "^18.18.0",
    "autoprefixer": "^10.4.19",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "postcss": "^8.4.39",
    "typescript": "~5.4.2"
  }

@JulienLecoq
Copy link

megaparsecs superior to React in almost every aspect

It's sad indeed, but Angular is not megaparsecs superior to React in almost every aspect. The verbosity of Angular is a big drawback imho. You have to double imports things such as components, enum and so on when you need to use them inside your components.. You have to add to every component standalone: true when you want to use them as "regular" component like in any modern framework (although that should not be true after v19). You have to add a selector name to every component. There is too many ways of doing things, styles, styleUrls, styleUrl just for styling a component whereas a single and standard way could be sufficient. Overall, I think the whole @Component() approach could be optional or removed and we could just replace it by a single render() method inside of classes... Furthermore, currently the framework is in a big transition which makes it hard for new programmer to learn it. The docs are not always up to date, they are some recommendations that should not be true anymore, they even made an RFC for that recently. And, for a very long time, the framework was RXJS oriented which is a big nonsense imho. It just adds a lot of complexity for no reasons in most cases. Fortunately, there is a shifting toward signals.

So no, Angular is not megaparsecs superior to React in almost every aspect.

@on3dd
Copy link

on3dd commented Oct 30, 2024

I am currently using the following solution to overcome this issue using Angular 18 with SSR, maybe it will help someone.

supabase.service.ts

@Injectable({ providedIn: 'root' })
export class SupabaseService {
  private _initFinished$ = new ReplaySubject<void>(1);
  readonly initFinished$ = this._initFinished$.asObservable();

  public client!: SupabaseClient;

  initClient() {
    this.client = createClient(<...>);
    this._initFinished$.next();
  }
}

auth.service.ts

@Injectable({ providedIn: 'root' })
export class AuthService {
  private readonly supabaseService = inject(SupabaseService);

  constructor() {
    this.supabaseService.initFinished$.pipe(first()).subscribe(() => {
      this.supabaseService.client.auth.getSession().then(({ data }) => {
        <...>
      });
    });
  }

app.component.ts

@Component({ ... })
export class AppComponent {
  private readonly supabaseService = inject(SupabaseService);

  constructor() {
    afterNextRender(() => {
      this.supabaseService.initClient();
    });
  }
}

@lennybakkalian
Copy link

lennybakkalian commented Oct 30, 2024

It's sad indeed, but Angular is not megaparsecs superior to React in almost every aspect. The verbosity of Angular is a big drawback imho. You have to double imports things such as components, enum and so on when you need to use them inside your components.. You have to add to every component standalone: true when you want to use them as "regular" component like in any modern framework (although that should not be true after v19). You have to add a selector name to every component. There is too many ways of doing things, styles, styleUrls, styleUrl just for styling a component whereas a single and standard way could be sufficient. Overall, I think the whole @Component() approach could be optional or removed and we could just replace it by a single render() method inside of classes... Furthermore, currently the framework is in a big transition which makes it hard for new programmer to learn it. The docs are not always up to date, they are some recommendations that should not be true anymore, they even made an RFC for that recently. And, for a very long time, the framework was RXJS oriented which is a big nonsense imho. It just adds a lot of complexity for no reasons in most cases. Fortunately, there is a shifting toward signals.

So no, Angular is not megaparsecs superior to React in almost every aspect.

There's someone yapping around.

Angular has put a strong focus on being backwards compatible. That's why deprecated methods/fields still exist.
standalone is not (yet) set to true by default for this reason.

The same applies to styleUrls and styleUrl. In react you have to add a library for every little thing. in the end you have a fat dependency on different maintainers.

a render() method? angular is very different from react because e.g. template and logic are separated for a good reason. look at the react components nowadays. long tailwind classes + state logic + props nightmare all in one file. terrible to maintain.

On a more neutral note, it is difficult to compare these two things. one is a framework and the other is a library (unless you are talking about e.g. nextjs)

But I also have to admit that as far as ssr is concerned, nextjs is clearly superior.

@delongZhai
Copy link

This is a nightmare bug to work with.

I am using Angular because I was familiar with it, even for SSR, I still use Angular. But the problem with all above now, since it has been siting for a long time, is that some of the key feature just can't be used.

Anonymous Sign-In is a important functionality. But this temp fix disable the ability to use it.
"overrides": { "@supabase/supabase-js": { "@supabase/auth-js": "2.61.0" } }

I hope that the temp fix doesn't have to be rely upon for too long because it will hurt the longer you wait

@on3dd
Copy link

on3dd commented Oct 30, 2024

@delongZhai Hey, have you managed to get this to work with SSR? I posted my solution above that solved the main problem for me, but I quickly ran into a limitation of that solution when I tried to make an AuthGuard based on user$ from AuthService. That would have worked fine if it weren't for the problem that brought us all here.

I'm almost in despair. It looks like I'll have to disable SSR after all, because the devs are too lazy to fix this problem even in 10 months. What a shame. I don't think I'll ever try Supabase on my projects again after this.

@delongZhai
Copy link

delongZhai commented Oct 30, 2024

hey @on3dd

I would recommend you to use isPlatformBrowser fn to check if it's being run in the browser again.

Here is my entire code

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [
    RouterOutlet,
    MobileMenuComponent,
    HeaderComponent,
    FooterComponent,
  ],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss',
})
export class AppComponent {
  title = 'cbd-store';

  constructor(
    @Inject(PLATFORM_ID) private platformId: Object,
    private supabase: SupabaseService
  ) {}

  ngOnInit(): void {
    if (isPlatformBrowser(this.platformId) && !this.supabase.client) {
      this.supabase.initialize();
    }
  }
}

@delongZhai
Copy link

@delongZhai Hey, have you managed to get this to work with SSR? I posted my solution above that solved the main problem for me, but I quickly ran into a limitation of that solution when I tried to make an AuthGuard based on user$ from AuthService. That would have worked fine if it weren't for the problem that brought us all here.

I'm almost feel desperate. It looks like I'll have to disable SSR after all, because the devs are too lazy to fix this problem even in 10 months. What a shame. I don't think I'll ever try Supabase on my projects again after this.

There's still a resolution I can think of, depending on how complex your system is, which is to ditch the supabase browser client, but to use supabase server client entirely, which is a bit more nasty. But hey nextjs is doing that, and I think if you are fine with it, you can as well.

@delongZhai
Copy link

delongZhai commented Oct 30, 2024

@on3dd and if you switch to server, for getSession, you need to use getUser.

here is the warning from their nextjs page.

Be careful when protecting pages. The server gets the user session from the cookies, which can be spoofed by anyone.

Always use supabase.auth.getUser() to protect pages and user data.

Never trust supabase.auth.getSession() inside server code. It isn't guaranteed to revalidate the Auth token.

It's safe to trust getUser() because it sends a request to the Supabase Auth server every time to revalidate the Auth token.

https://supabase.com/docs/guides/auth/server-side/nextjs?queryGroups=router&router=pages

@on3dd
Copy link

on3dd commented Oct 30, 2024

hey @on3dd

I would recommend you to use isPlatformBrowser fn to check if it's being run in the browser again.

Here is my entire code

` @component({ selector: 'app-root', standalone: true, imports: [ RouterOutlet, MobileMenuComponent, HeaderComponent, FooterComponent, ], templateUrl: './app.component.html', styleUrl: './app.component.scss', }) export class AppComponent { title = 'cbd-store';

constructor( @Inject(PLATFORM_ID) private platformId: Object, private supabase: SupabaseService ) {}

ngOnInit(): void { if (isPlatformBrowser(this.platformId) && !this.supabase.client) { this.supabase.initialize(); } } } `

@delongZhai Thank you, PLATFORM_ID is something I had already forgotten about.

@delongZhai Hey, have you managed to get this to work with SSR? I posted my solution above that solved the main problem for me, but I quickly ran into a limitation of that solution when I tried to make an AuthGuard based on user$ from AuthService. That would have worked fine if it weren't for the problem that brought us all here.
I'm almost feel desperate. It looks like I'll have to disable SSR after all, because the devs are too lazy to fix this problem even in 10 months. What a shame. I don't think I'll ever try Supabase on my projects again after this.

There's still a resolution I can think of, depending on how complex your system is, which is to ditch the supabase browser client, but to use supabase server client entirely, which is a bit more nasty. But hey nextjs is doing that, and I think if you are fine with it, you can as well.
Sounds like something worth considering.

I don't have as much experience with Angular SSR as I do with Next.js, but doing all this things on the server sounds like a real pain, especially in Angular because you won't have those API handlers of Next.js that can fix things a bit 😖

@delongZhai
Copy link

delongZhai commented Oct 30, 2024

hey @on3dd
I would recommend you to use isPlatformBrowser fn to check if it's being run in the browser again.
Here is my entire code
@component({ selector: 'app-root', standalone: true, imports: [ RouterOutlet, MobileMenuComponent, HeaderComponent, FooterComponent, ], templateUrl: './app.component.html', styleUrl: './app.component.scss', }) export class AppComponent { title = 'cbd-store'; constructor( @Inject(PLATFORM_ID) private platformId: Object, private supabase: SupabaseService ) {} ngOnInit(): void { if (isPlatformBrowser(this.platformId) && !this.supabase.client) { this.supabase.initialize(); } } }

@delongZhai Thank you, PLATFORM_ID is something I had already forgotten about.

@delongZhai Hey, have you managed to get this to work with SSR? I posted my solution above that solved the main problem for me, but I quickly ran into a limitation of that solution when I tried to make an AuthGuard based on user$ from AuthService. That would have worked fine if it weren't for the problem that brought us all here.
I'm almost feel desperate. It looks like I'll have to disable SSR after all, because the devs are too lazy to fix this problem even in 10 months. What a shame. I don't think I'll ever try Supabase on my projects again after this.

There's still a resolution I can think of, depending on how complex your system is, which is to ditch the supabase browser client, but to use supabase server client entirely, which is a bit more nasty. But hey nextjs is doing that, and I think if you are fine with it, you can as well.
Sounds like something worth considering.

I don't have as much experience with Angular SSR as I do with Next.js, but doing all this things on the server sounds like a real pain, especially in Angular because you won't have those API handlers of Next.js that can fix things a bit 😖

That's correct, for server-side code, I've been especially worried about. And I will continue to make sure my code can be migrated to client side the moment it's resolved. But apparently that's the only workaround for developer who not only need anonymous login and also need to use supabase, and Angular.

You may need to write some Express code to define the routes.

@delongZhai
Copy link

For anyone who still blocked by this issue, please prioritize it by submitting a ticket to supabase support in your projects dashboard. The longer we wait, the longer we are blocked by it

@JulienLecoq
Copy link

JulienLecoq commented Oct 30, 2024

It's sad indeed, but Angular is not megaparsecs superior to React in almost every aspect. The verbosity of Angular is a big drawback imho. You have to double imports things such as components, enum and so on when you need to use them inside your components.. You have to add to every component standalone: true when you want to use them as "regular" component like in any modern framework (although that should not be true after v19). You have to add a selector name to every component. There is too many ways of doing things, styles, styleUrls, styleUrl just for styling a component whereas a single and standard way could be sufficient. Overall, I think the whole @Component() approach could be optional or removed and we could just replace it by a single render() method inside of classes... Furthermore, currently the framework is in a big transition which makes it hard for new programmer to learn it. The docs are not always up to date, they are some recommendations that should not be true anymore, they even made an RFC for that recently. And, for a very long time, the framework was RXJS oriented which is a big nonsense imho. It just adds a lot of complexity for no reasons in most cases. Fortunately, there is a shifting toward signals.
So no, Angular is not megaparsecs superior to React in almost every aspect.

There's someone yapping around.

Angular has put a strong focus on being backwards compatible. That's why deprecated methods/fields still exist. standalone is not (yet) set to true by default for this reason.

The same applies to styleUrls and styleUrl. In react you have to add a library for every little thing. in the end you have a fat dependency on different maintainers.

a render() method? angular is very different from react because e.g. template and logic are separated for a good reason. look at the react components nowadays. long tailwind classes + state logic + props nightmare all in one file. terrible to maintain.

On a more neutral note, it is difficult to compare these two things. one is a framework and the other is a library (unless you are talking about e.g. nextjs)

But I also have to admit that as far as ssr is concerned, nextjs is clearly superior.

Yep, I understand why a lot of those "bad things" are still there, even though Angular has a strong focus on being backwards compatible that still does not make it megaparsecs superior to React in almost every aspect, come on...

I highly disagree on the take "long tailwind classes + state logic + props nightmare all in one file is terrible to maintain". That's why component are there. You can just decompose when it starts to be too big. And it's not mandatory to put everything in one file or use tailwind, you can use css modules and put your css in another file if you prefer to do so (at least with NextJS).
I still often myself not put everything into one file in Angular but this is mainly because it is long/verbose to create components in Angular and also because Angular is creating a supplementary tag every time you create a component, which makes styling afterwards more difficult and impact perf compared to other modern frameworks :(

I agree that on some points they're not comparable since they don't have the same amount of features. It would be more fair to compare to a full fledge React framework such as NextJS. But the component authoring format can be compared and the React one is less verbose, at least for the creation of a basic component (without JSX and so on involved).

I don't say Angular is shit and shouldn't be used, in fact Angular becomes much better release after release, less verbose and more enjoyable to use. But saying that it is megaparsecs superior to React in almost every aspect is such a lie.

@kangmingtay
Copy link
Member

Hi everyone, apologies for the lack of replies by the team in this thread - the auth team isn't the most familiar with angular here but we want to understand the root cause of this issue so we can fix it properly without having to do something hacky like downgrading the version or asking angular users to remove the lock.

Angular throws an error saying 'Acquiring an exclusive Navigator LockManager lock immediately failed'.

Specifically, is Angular not able to access the Navigator Lock API? Based off a quick search, it seems like Angular 17 / 18 is compatible with the Navigator Lock API.

@hf has also looked into this earlier this year and we suspect that it's an issue with an unhandled promise rejection - supabase/auth-js#830 (comment)

we would really appreciate any help from the community with understanding more about the inner workings of angular here!

@delongZhai
Copy link

hey @kangmingtay , thank for the reply. I don't have much knowledge about navigator lock api. Neither can I find much detail within Angular community.

But a quick look into this, it forces me to think if there's anything that's wrong with using navigator lock api with zone.js. Zone.js is a basically how Angular magically update the view whenever there the app runs change detection.

https://stackoverflow.com/a/52392036

I wonder if using zoneless would make any difference. If it does, perhaps for angular team, we need to move it off the main thread to use web worker? I'm writing to just propose potential problems. I am not certain that it is the case since zone.js has been a while for a long time. But can you also explain how that navigator lock work? Currently, zonejs is running as default, with known issue for SSR, and very few have zoneless implemented. If you have time to look into it, that would be great. Thank you

https://angular.dev/guide/experimental/zoneless

a topic with zone.js pollution. https://blog.bitsrc.io/angular-mitigating-zone-pollution-in-angular-22734b19576e

@hf
Copy link
Contributor

hf commented Dec 6, 2024

The way Zone.js works with promises is that it patches the native Promise API so it tracks the "execution context" in very hacky ways.

The Navigator Locks API uses native promises from the looks of it. Meaning -- the browser's internal Promise is being used, not the patched up Zone.js one. This is why the context is being lost and the weird log messages appear.

As far as I am aware, there's really no way to fix this. One way to get rid of the issue is to just not use the navigator lock -- which I strongly do not recommend as it would cause other subtle bugs in your application where people are randomly logged out. To do that, set the lock Auth option to a noop function in createClient.

@hf
Copy link
Contributor

hf commented Dec 6, 2024

Actually maybe one thing that could help is if we were to wrap the lock promise with the patched promise. I know that Dexie's zone.js equivalent likes that.

Something like this: supabase/auth-js#989

hf added a commit to supabase/auth-js that referenced this issue Dec 6, 2024
…#989)

Wraps the `navigator.locks.request()` function with a plain Promise as
libraries such as zone.js patch this object to track execution context.
It appears that this browser API uses a native promise that's not
patched, causing the tracking context to be lost.

It is believed that wrapping this non-zone.js Promise returned by the
browser with a promise that's patched by zone.js can help the situation.

Related:
- supabase/supabase-js#936
- #830
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests