Skip to content

Web Lock API instead of Mutex - #44

Open
langsamu wants to merge 4 commits into
mainfrom
no-mutex
Open

langsamu wants to merge 4 commits into
mainfrom
no-mutex

Conversation

@langsamu

@langsamu langsamu commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

@langsamu langsamu changed the title Wwb Lock API instead of Mutex Web Lock API instead of Mutex Sep 18, 2026
@langsamu
langsamu marked this pull request as ready for review September 18, 2026 14:36

@jeswr jeswr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the documentation comment is directly relevant to this PR. The rest can be applied separately in follow ups.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like NodeJS support for the Web Lock API was added in Node 24. Node 22 is in maintenance until April 2027 - we should therefore document that Node v24 is the minimum supported node version.

I'd also double check they haven't backported it before writing the exact version.

Comment on lines +182 to +183
const {promise: responseFromPopup, reject: cancelCodeRequest, resolve: respondWithCode} = Promise.withResolvers<string>()
signal.throwIfAborted()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not throw before creating the promise.

Comment thread src/IdpPicker.ts
this.#dialog.addEventListener("close", onClose, onlyOnce)

return await promise
return await promise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return await promise
return promise

Comment thread src/WebIdPicker.ts
this.#dialog.addEventListener("close", onClose, onlyOnce)

return await promise
return await promise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return await promise
return promise

// One flow at a time, fellas
using _ = await this.#mutex.acquire()
return await navigator.locks.request("AuthorizationCodeFlow.getCode", async _ => {
this.#authorizationUri = authorizationUri

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to do this after the check of whether the signal is aborted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants