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

set/parse race conditions #53

Open
carlofaessler opened this issue Jun 1, 2023 · 0 comments
Open

set/parse race conditions #53

carlofaessler opened this issue Jun 1, 2023 · 0 comments

Comments

@carlofaessler
Copy link

It would be better if the IP and UA could be passed directly to the parse() method rather than having to use set() before.

let ret = udgerParser.parse({
    ua:'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
    ip:'2A02:598:7000:116:0:0:0:101'
});

The parser should be stateless to avoid problems in race conditions. For example it could happen that two requests to our service which accesses the global Udger instance from inside an async function happen at the same time, leading to a set() -> set() -> parse() -> parse() sequence where the second request overwrites the IP and UA of the first request before the first request gets to the parse() method call

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

No branches or pull requests

1 participant