lokalise / node-lokalise-api

Lokalise API v2 Node.js client.

Home Page:https://lokalise.github.io/node-lokalise-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running a single instance client throws error "Your token is currently used to process another request. We do not support concurrent requests."

basharov opened this issue · comments

Describe the bug
I have a nodejs-based client which sends requests to Lokalise via node-lokalise-api library.

The code is as simple as this Express endpoint:

app.get('/project/:projectId', async (req, res) => {
    try {
        const project = await lokaliseApi.projects.get(req.params.projectId)
        res.json(project)
    } catch (err) {
        console.log(err)
        res.json(err)
    }

})

Returns this:

{ message: 'Your token is currently used to process another request. We do not support concurrent requests.',
  code: 423 }

To Reproduce
Call the same endpoint 5-10 times a minute.

Expected behavior
Error message seems to be wrong to me because I clearly run a single instance client, not multiple clients. I don't have a clear picture of what causes this error and how long to wait before it starts to return proper data again.

Your environment:

  • Node version 10.15.3
  • MacOs 10.14.6 (18G95)

Additional context
Thank you!

Thank you for reporting this! We will investigate.

Are you sure your app is not accessing API in parallel? We used to have a similar issue and that was the case. We don't see any issues on our side and no similar errors were reported...

I have just started the app after the weekend pause. I absolutely know that nobody ran it while weekend because I am the only developer working on it now. Right from the start I am seeing the same 423 error.

Is there any information I can provide you with to investigate this issue?

Thanks!

Seems like I have a clue why it's happening.
My react app runs 3 simultaneous requests to load data about projects, languages and keys. It seems like once one request to Lokalise API is still running, the other one is being called and that's why the error is returned.

I will check how I can restructure my client code to make it more like synchronous.

Thanks!

Yes, that's what I was talking about: some parts of the code try to access API in parallel, and that's why the error happened. I'm glad we idenfitied the cause of the problem!