supabase-js: Acquiring an exclusive Navigator LockManager failed

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.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 61
  • Comments: 72 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@vv001 the override worked for me with @supabase/supabase-js@2.40.0 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"
  }
}

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

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: https://github.com/supabase/gotrue-js/pull/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

Downgrading is a very bad approach Because the new version has new features and bug fixes We can temporarily downgrade to solve this problem But it’s been several months now, and I think a formal repair should be carried out

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.

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

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.

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"
    }
  },

FYI this is what resolved it for me with yarn.

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

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

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

seeing this with supabase 2.39.7, angular 17.2.1

I would also like this issue to get some love.

What I can’t understand is if today it’s possible to use supabase with angular / ionic project or if this problem can produce bugs

Ciao Davide, I’m using Supabase with an Ionic/Angular project and now it’s working with no errors and no issues. I’m using the latest version of all the frameworks (“@ionic/angular”: “8.4.1” - “@angular/cli”: “19.0.5” - “@supabase/supabase-js”: “2.47.10”) and removed Zone.js (using provideExperimentalZonelessChangeDetection in main.ts), and I don’t see this issue anymore.

Paolo

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

use provideExperimentalZonelessChangeDetection() fixed the error for me ✌🏼

@vv001 the override worked for me with @supabase/supabase-js@2.40.0 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 solved the issue for me.

The fix didn’t help

  • Angular version: 19.1.0
  • Supabase version: 2.48.0 Image

I’m using the same version and workaround, I still see the error logged but the SDK still works to send/receive data from my database so I’m treating it more as a warning than an error for now.

I also tested going fully zoneless on my application which did indeed remove the error entirely (although quite a big refactor for a large codebase, so planning to do so slowly over time with the other workaround in place)

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

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() }
});

@vv001 the override worked for me with @supabase/supabase-js@2.40.0 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

guys, thank you very much, we managed to solve the problem. to sum up:

in package.json:

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

in app.config.ts in appConfig var .providers add provideExperimentalZonelessChangeDetection() remove provideZoneChangeDetection({ eventCoalescing: true })

in angular.json in polyfills mentions removed "zone.js"

at the end npm i ofc

Hi all, I solved removing Zone.js from my Angular project, moving to Zoneless change detection with the use of Signals. Here what I did:

  1. In main.ts add this: “provideExperimentalZonelessChangeDetection()” in the providers array
  2. In polyfills.ts comment these lines: “import ‘./zone-flags’;” and “import ‘zone.js’;”
  3. Convert any variable in the project that updates the user interface to a Signal

I hope this can help! Kind regards,

Paolo

I’m using Supabase 2.47.10, and the problem persists.

What I can’t understand is if today it’s possible to use supabase with angular / ionic project or if this problem can produce bugs

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: https://github.com/supabase/auth-js/pull/989

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.

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

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.

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();
    });
  }
}

@mungo-pod See this comment above, the override needs to be on "@supabase/auth-js" now.

@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

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.

@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?