rogierschouten/async-lock

process not set when acquiring lock

Closed this issue · 5 comments

Not sure what has changed in chrome, but we are now getting a process undefined error from this package.

image

updated this line to avoid the error..

and subsequently received the same error on.
image

@kvandelden thank you for reporting. As you can see in the readme, I only merge PRs for this package, as I am not the original owner and I'm not using it myself. Any chance of getting a fix in ?

sr258 commented

Have you updated to Webpack 5 by any chance? Webpack 5 doesn't contain the polyfill to add process to the bundle by default anymore. That's why process is undefined (it doesn't exist in the browser).

This is what happened in a new project I set up with Webpack 5. Older ones with Webpack 4 don't have this issue.

The domain feature is deprecated in nodejs, see also here. IIUC it's referenced in async-lock to provide the feature of "domain-reentrant locks". As long as the domain feature exists in nodejs, there's a chance that someone wants domain-reentrant locks. And since there's a polyfill for browsers, one could even use them there (not sure if they work there, but let's assume so). In both cases, the Domain implementation would be loaded by the application code. So async-lock only needs to move on gracefully when the process.domain isn't present, and perhaps throw an error if someone requests domain-reentrant locks in that case. I can send a PR.

Closed through #42 and released as v1.2.8